loverajoel / jstips

This is about useful JS tips!
http://jstips.co
GNU General Public License v3.0
12.5k stars 803 forks source link

Get the file extension #342

Closed richzw closed 8 years ago

richzw commented 8 years ago

Get file extension

TL;DR;

Several solutions are posted here to get the more efficient way to get the file extension.

@richzw

Extra

kurtextrem commented 8 years ago

Great tip.

:shipit:

loverajoel commented 8 years ago

nice :shipit:

sjfkai commented 8 years ago

:shipit:

neighborhood999 commented 8 years ago

:shipit:

zenopopovici commented 8 years ago

:shipit: . Nice work!

gromgit commented 8 years ago

A couple of issues:

Your _How does it work? section is a word-for-word copy of the linked StackOverflow answer. You should probably rewrite it in your own words to avoid accusations of plagiarism. (The other reason to do so is that the original explanation actually leaves out a couple of details.)

You should also make a note that getFileExtension3() is the only correct implementation of the three. I suggest making a table of the results of all three functions called over all your test strings, so that the differences become obvious.

richzw commented 8 years ago

@gromgit, thank you for your comments, I have updated this tip per your suggestion.

loverajoel commented 8 years ago

@richzw thanks for your tip! really good tip!