31. JavaScript Objects: Object to Primitive Conversion

preview_player
Показать описание
#MissXing #JavaScript #JavaScriptObject

What happens when objects are added obj1 + obj2, subtracted obj1 - obj2 or printed using alert(obj)?
There’s no conversion to boolean. All objects are true in a boolean context.
There exist only numeric and string conversions.
The numeric conversion happens when we subtract objects or apply mathematical functions. For instance, Date objects (to be covered in the chapter Date and time) can be subtracted, and the result of date1 - date2 is the time difference between two dates.
As for the string conversion – it usually happens when we output an object with alert(obj)and in similar contexts.

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

You have clearly explained the most difficult topic in JavaScript. Thanks💯💝

MrAnik-xfnr
Автор

Thanks for the video and well detailed explanation. I was finding this topic slightly hard while going through javascriptinfo. I am feeling lucky that i stumbled upon this video after reading that article and after watching the explanation i feel confident.

RanjeetKumar-fooi
Автор

Great stuff, loved it. Nothing better than a cute teacher.

moodymonstrosity
Автор

Can I call you by teacher ? I've been learning a lots from your channel - these knowledge bring me further on my career. Thank you so much ^.^
Especially, you are really good teacher, love the way you teaching - so easy to understand :>

nhatnguyenthe
Автор

iam the viewer 1000 i just wanted to complete it for you

Rajelbrahim