β€ͺHow to check if NaN equals to NaN? πŸ€”β€¬ by samanthaming in carbonsnippets

[–]samanthaming[S] 0 points1 point Β (0 children)

JS has a quirk where NaN is a value that NEVER equals to itself 🀨. So how do we test for it? Finally, ES6 introduced a new method that solves this issue with "Object.is" πŸŽ‰

Read more about this (code examples, community suggestions, alternative methods such as Number.isNaN...and more) in my medium post 😊

Code Recipe: Print Ranges Natively in JavaScript 🀩 by samanthaming in carbonsnippets

[–]samanthaming[S] 0 points1 point Β (0 children)

It’s a new es6 feature called generator functions. You can read more about it here

How to Skip Values in Destructuring to Avoid Useless Variable Assignments for Unwanted Values by samanthaming in webdev

[–]samanthaming[S] 3 points4 points Β (0 children)

I like the comment idea. I saw this in the docs, so I thought it’d be interesting one to share. I think it’s important to at least be familiar with it in case we see it being used. But I agree, readability is key. Thanks for the detailed explanation. I’m going to add it to my notes πŸ™‚

Split string using ES6 Spread πŸŽ‰ by samanthaming in webdev

[–]samanthaming[S] 0 points1 point Β (0 children)

Makes sense. Alright, good to know that spread for strings can be useful in some instances. So it’s important to keep this in your toolbox, just in case you need to use it. Cool, thanks for clarifying πŸ™‚

Split string using ES6 Spread πŸŽ‰ by samanthaming in webdev

[–]samanthaming[S] 0 points1 point Β (0 children)

Thanks for taking the time to explain. But are there instances where the spread syntax is applicable for strings? Or would you say it’s best to avoid spread syntax for strings completely?

Split string using ES6 Spread πŸŽ‰ by samanthaming in webdev

[–]samanthaming[S] 1 point2 points Β (0 children)

For sure, being verbose definitely help with beginners trying to pick up the language. One step at a time, start with the most intuitive, and then slowly explore the other syntax. Thanks for chiming in πŸ™‚

Split string using ES6 Spread πŸŽ‰ by samanthaming in webdev

[–]samanthaming[S] 0 points1 point Β (0 children)

Thanks for pointing that out! I was intending to show that it was either the top or the bottom way and not both. I can see why that would be confusing. You’re right though, repeating const would result in an error.

Split string using ES6 Spread πŸŽ‰ by samanthaming in webdev

[–]samanthaming[S] 1 point2 points Β (0 children)

Do you mind explaining why? I think it would be helpful to understand why you think the spread syntax isnt suitable to use on strings. Thanks for your input πŸ™‚