How to extract the file extension from the filename

• 1 min read

Here the lovely snippet to grab the extension from the file name in javascript:

const filename = 'myFile.pdf'
const extension = filename.split('.').pop()
// pdf