How to get the file extension from a filename using Javascript

No Comments
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);

Image Credits: Photo by Isis França on Unsplash.

Related Articles

No results found

Leave a Reply

avatar
  Subscribe  
Notify of
Menu
Copy link