r/learnjavascript • • Nov 03 '20

22 Javascript String Methods 🔥

201 Upvotes

9 comments sorted by

3

u/skerit Nov 03 '20

Be careful when using String#length, some unicode characters count for 2. Take "🔥" for example. Splitting this string in half will break the emoji.

1

u/Harbltron Nov 03 '20

WOW, includes() is almost perfect for conditionals in the game I'm making; if the word in question exists in the text prompt then I can use that as a flag instead of explicitly storing conditions elsewhere.

Thanks!

2

u/mothzilla Nov 03 '20

Hmm. There's not much here that autocomplete couldn't tell me.

3

u/Merry-Lane Nov 03 '20

I died a little at « emittion »

3

u/imapersonithink Nov 03 '20 edited Nov 03 '20

It's best practice to use 'const' instead of 'let', unless you plan on changing the value.

https://github.com/airbnb/javascript#references

2

u/[deleted] Nov 03 '20

This is really great... just need to fix up a few small details, but overall really awesome

1

u/Roshia188 Nov 03 '20

Very cool, thanks!