How to extract the file extension from the filename

Posted on November 5, 2021

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

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