How to get the current logged in username in SharePoint 2013

Steps

  1. Create page in your sharepoint site.
  2. Edit the page and add a content editor webpart in sharepoint your page.
  3. Copy hte below scitp in notepad and save it as a .js file in your site asset.
  4. copy hte path of your notepad and paste it in a CEWP edit webpart link.
  5. save the page .
  6. out put will be displayed in alert box.
  1. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>  
  2. <script type="text/javascript">     
  3.     var thisUserAccount ;              
  4.     $(document).ready(function() {    
  5.     thisUserAccount= $().SPServices.SPGetCurrentUser({    
  6.     fieldName: "Title",    
  7.     debug: false    
  8. });    
  9.     
  10. alert(thisUserAccount);    
  11. });    
  12. </script>    
Thanks for learning.