Type Conversion | JavaScript For Beginners | JavaScript Tutorials | Learn JavaScript In 2020

preview_player
Показать описание
Learn about type conversion in JavaScript – Learn one of the most popular coding languages

Resources

Want to learn more?

#javascript #js #webdevelopment #learnjs
Рекомендации по теме
Комментарии
Автор

Can you please clarify String to Number starting at 5:46 -- When you remove the single quotes we can see that the "typeof" has already switched to "number." You comment that the "toFixed" function isn't working yet. So then you go back in the code and add the "Number" function and wrap the "5" in parentheses, but nothing changes in the console. The "typeof" still says "number" (just as it did before) and the "toFixed" text in the console is also unchanged, but you definitively say "and the type has been changed to a number, " as if it is a new change.

Are you just showing that you can technically perform the String to Number conversion either way? (i.e. removing string quotes and using a plain number OR by using the "Number" function and wrapping in parentheses (in which case you can keep the string quotes as long as they are inside the parentheses and it will still be changed to a number))

If that is what you were showing is one of them considered best practice?

Additionally, I hate to be a pain, but I'm also confused by 9:17 on. You've just finished proving that although the array is a list of numbers, it is labeled as "NaN" because technically it's not a number, it's still an array. You suggest that the way to get around this is to use the "ParseInt" function, but then you don't actually show how to get around it using the "ParseInt" function. You show how the "ParseInt" is used for rounded numbers and how "ParseFloat" needs to be used for numbers with decimals...but I'm still not sure how it solves the problem of the array being output as NaN?

I know this is a lot, but everything has been so clear and easy to understand so far.
This particular video hasn't resonated quite as well with me and I still want to make sure I'm grasping the concepts before moving on.

Thanks very much, Dary!

ryanwagner