Created
October 23, 2018 17:59
-
-
Save juanlopezdev/277b65cdb109cb6a4a3bad844488afec to your computer and use it in GitHub Desktop.
[Obtener extension de un archivo en javascript] Funciones que retornan la extensión de un archivo a traves de su nombre #javascript #utilidades
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFileExtension1(filename) { | |
return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename)[0] : undefined; | |
} | |
function getFileExtension2(filename) { | |
return filename.split('.').pop(); | |
} | |
function getFileExtension3(filename) { | |
return filename.slice((filename.lastIndexOf(".") - 1 >>> 0) + 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment