How to get the file extension from a filename using Javascript

7 sec read

var filename = 'myFile.jpg';
var ext = filename.split('.').pop();  //We split the filename on every instance where the . is found and then getting the last element in the array using the pop() function 
alert(ext);

Last Updated On March 20, 2018

Leave a Reply

avatar
  Subscribe  
Notify of