Тёмный

JS Type Casting, Converting, and Coercion 

Steve Griffith - Prof3ssorSt3v3
Подписаться 103 тыс.
Просмотров 3,3 тыс.
50% 1

Опубликовано:

 

30 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 26   
@aakashsingh604
@aakashsingh604 4 года назад
I have learned a lot by coming to your channel. Thanks a lot for it!
@LR-bc8js
@LR-bc8js Год назад
My favorite teacher on RU-vid!!
@Robert-cw9ev
@Robert-cw9ev 4 года назад
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.
@serhii113
@serhii113 4 года назад
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
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 года назад
I've updated my code Gist to reflect the two Array differences for +[1] and +[1,2]. The Arrays get turned into the Primitive string values "1" and "1,2" before being converted to Numbers which is why we get the 1 and NaN results. Not sure why I had 0 written for the Objects. They will always be NaN. Thanks for pointing it out.
@chesterxp508
@chesterxp508 2 года назад
Another very cool tutorial!
@BrendanMetcalfe
@BrendanMetcalfe 4 года назад
Looks like you put in a lot of work on this! Good work man
@rmnkot
@rmnkot 4 года назад
Very important core knowledge! Thanks, as always!
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 года назад
My pleasure!
@katherineprokofieva5707
@katherineprokofieva5707 3 года назад
thanks for your video!
@joaovaz3473
@joaovaz3473 4 года назад
Great video, always! A question: isn't an empty array a falsy value?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 года назад
Nope. Everything that is not falsy is truthy in JS. The falsy values are: false, 0, "", null, undefined, and NaN. Arrays are Objects. They are not on the list, so they are truthy. Run this: if( [ ] ){ console.log('array is truthy'); } However, think about this - Convert an empty Array to a String and you get "". Convert that into a Boolean and you get false.
@joaovaz3473
@joaovaz3473 4 года назад
@@SteveGriffith-Prof3ssorSt3v3 Ahh, ok. Thanks!
@siddharthapothan5165
@siddharthapothan5165 3 года назад
Your videos are really helpfull, learnt a lot. But is Number({}) value 0? Thanks!!!
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 года назад
That was a copy paste error in my comments. The gist was updated to show that converting an empty object to a number gives you NaN.
@tracyadams6787
@tracyadams6787 4 года назад
Great video. Any chance you could post the link to the operator precedence reference?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 года назад
It is in the code gist linked to in the description
@guignolguignol5340
@guignolguignol5340 4 года назад
is there in ASP classic or javascript function like CURL in PHP
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 года назад
fetch( ) is the modern JavaScript method for making HTTP Requests. XMLHttpRequest is the old JS method for making HTTP Requests.
@guignolguignol5340
@guignolguignol5340 4 года назад
@@SteveGriffith-Prof3ssorSt3v3 Thank you, Mr. Steve, in your view, what you will use to do better
@jassihambran
@jassihambran 4 года назад
hey steve. Could you help us in how to setup terminal to run javascript files without any extension?Thanks in advance
@aarong9327
@aarong9327 4 года назад
Type node in your terminal and it'll run the code in that file.
@jassihambran
@jassihambran 4 года назад
@@aarong9327 it does not. When i try it says file could not be found.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 года назад
It does on Linux and MacOS. I haven't tried on Windows.
@webb-developer
@webb-developer 11 месяцев назад
@NairiKhachatryan
@NairiKhachatryan Месяц назад
let emptyStr = '' Number(emptyStr) // 0
Далее
JS Code Structure Moving Beyond Beginner
21:31
Просмотров 13 тыс.
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
Самое большое защитное стекло
00:43
Ten Steps to Mastering the Fetch API
2:19:52
Просмотров 47 тыс.
If __name__ == "__main__" for Python Developers
8:47
Просмотров 410 тыс.
Chrome Dev Tools Source Panel and Breakpoints
18:21
Просмотров 6 тыс.
Coercion in Javascript
14:53
Просмотров 37 тыс.
How to Use the New JS Object GroupBy Method
18:17
Просмотров 3,9 тыс.
JavaScript Under The Hood [4] - Memory Storage
12:58
Просмотров 48 тыс.
7a. JavaScript Explicit vs. Implicit Conversions
11:52
Просмотров 1,3 тыс.