Are JavaScript Primitives Actually Objects?

preview_player
Показать описание
In this tutorial we revisit and important yet fundamental concept in JavaScript: The object wrapper associated with primitives.

Would you like to help keep this channel going?

For more resources on JavaScript:

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

What would be the purpose of using the constructor method, with the 'new' keyword, if the primative method is just as useful?

Martin
Автор

Please consider embracing dark mode. Great tutorials. I just have to wear sun glasses. I look super cool when I watch your videos. 😎

bmehder
Автор

I wonder in what cases it might be necessary to create object versions of primitives.

Time spent experimenting in the console is worthwhile to consolidate understanding of this as, in addition to primitives versus objects, other factors come into play when comparing variables - equality versus strict equality, coercion, and the fact that the object methods (valueOf, toString, toUpperCase etc.) return literals, not objects...

const numOb = new Number(4);
numOb === 4; // false
numOb == 4; // true
numOb == "4" // true
numOb === "4" // false
numOb.valueOf() == 4 // true
numOb.valueOf() == "4" // true
numOb.valueOf() === 4 // true
numOb.valueOf() === "4" // false
numOb.toString() == "4"; // true
numOb.toString() == 4; // true
numOb.toString() === "4"; // true
numOb.toString() === 4; // false

batchrocketproject
Автор

Hi coach,

I specialize in helping Udemy instructors attract more paid students. By optimizing your course with SEO and creating targeted awareness campaigns, we’ll boost visibility, reach, and enrollments. Let’s connect to explore how I can help your course grow!

Best,
Sarah

OsoweFunmilayo
visit shbcf.ru