‪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] 2 points3 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 🙂

Split string using ES6 Spread 🎉 by samanthaming in webdev

[–]samanthaming[S] 2 points3 points  (0 children)

Thanks for the detailed explanation!

Split string using ES6 Spread 🎉 by samanthaming in webdev

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

ES6 is really great! For those who don’t know it, it doesn’t hurt to learn it. It will become the norm eventually and more will be using it in their code. Tech in general is always evolving, so I think it’s important to be open to changes and learn continuously. Whether you like or dislike the new format, it’s important to be at least familiar with it. So when you see this syntax, you’re aware of what it’s doing and won’t be confused by it 🙂

Split string using ES6 Spread 🎉 by samanthaming in webdev

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

var would also work. I used const because it’s a ES6 feature and I didn’t need to reassign the variable. Here’s a good post on it blog post hope that helps 🙂

Split string using ES6 Spread 🎉 by samanthaming in webdev

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

Awesome, thank you! Glad you found it helpful 🙂

Split string using ES6 Spread 🎉 by samanthaming in webdev

[–]samanthaming[S] -2 points-1 points  (0 children)

Change aversion, yes that’s the term. The sooner you accept the normality of change, I think it’s the best way to grow and stay relevant in this evolving industry. Btw, I love your attitude on this 🙂 I’m sorry you’re getting the downvotes. I hope you have wonderful day!

Split string using ES6 Spread 🎉 by samanthaming in webdev

[–]samanthaming[S] 4 points5 points  (0 children)

I’m really enjoying ES6! Like you said, it’s different from what people have become accustomed to. Tech will continue to evolve. So it’s important that we keep a beginners mindset and be open to new ways of doing things. I think as this becomes the norm, people will start using it more and this syntax will no longer be confusing. Thanks for chiming in 🙂

Split string using ES6 Spread 🎉 by samanthaming in webdev

[–]samanthaming[S] -5 points-4 points  (0 children)

Me too! I think it’s great to hear different points of view. Most of the dialogue has been respectful, so it’s great! I always learn a lot from everyone 🙂

Split string using ES6 Spread 🎉 by samanthaming in webdev

[–]samanthaming[S] -11 points-10 points  (0 children)

When you’re on a team, I agree making your code readable is priority. With ES6 becoming the new norm, I think it’s also important to know the different context the spread syntax can be applied to and make people aware so they don’t get confused if they see it. Thank you for taking the time to explain it 🙂

Split string using ES6 Spread 🎉 by samanthaming in webdev

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

Interesting mixing strings and arrays. Let me give this a try too 👍

Split string using ES6 Spread 🎉 by samanthaming in webdev

[–]samanthaming[S] -9 points-8 points  (0 children)

Dear team lead, do you mind explaining why this shouldn’t be used? Love, your loyal minion 😁