JS Type Casting, Converting, and Coercion

preview_player
Показать описание
Basic conversion between strings and Numbers is a simple task most of the time. However, there is actually a lot going on behind the scenes when working with different JavaScript operators, their precedence, and converting, casting, and coercing values and objects between different primitive values.

Рекомендации по теме
Комментарии
Автор

I have learned a lot by coming to your channel. Thanks a lot for it!

aakashsingh
Автор

Very important core knowledge! Thanks, as always!

rmnkot
Автор

Thanks!

A couple of nuances ;)

+{} // NaN
+[1] // 1
+[1, 2] // NaN

"If an object has no primitive value, valueOf returns the object itself."
(c) MDN

serhii
Автор

Looks like you put in a lot of work on this! Good work man

BrendanMetcalfe
Автор

Thanks for video!
I've also looked at other explanations on internet and I found out that:
- "" to number is 0;
- [] to number is 0, because it first converts to string which is "", then it converts "" to number which is 0;
- "" == 0 its true. So equals operator converts both to number, which means that "" to number is 0.

Robert-cwev
Автор

Great video. Any chance you could post the link to the operator precedence reference?

tracyadams
Автор

Great video, always!
A question: isn't an empty array a falsy value?

joaovaz
Автор

Your videos are really helpfull, learnt a lot. But is Number({}) value 0? Thanks!!!

siddharthapothan
Автор

is there in ASP classic or javascript function like CURL in PHP

guignolguignol
Автор

hey steve. Could you help us in how to setup terminal to run javascript files without any extension?Thanks in advance

jassihambran
Автор

let emptyStr = '' Number(emptyStr) // 0

NairiKhachatryan