Nidhi Jagga’s Post

Back to Basics: The 8 Building Blocks of JavaScript. 🧱 Sometimes we get so caught up in frameworks like React or Angular that we forget the fundamental DNA of the language. JavaScript data types are divided into two main categories: 𝐏𝐫𝐢𝐦𝐢𝐭𝐢𝐯𝐞𝐬 and 𝐑𝐞𝐟𝐞𝐫𝐞𝐧𝐜𝐞𝐬. Knowing the difference is key to avoiding weird bugs (like accidental mutation). 1️⃣𝐓𝐡𝐞 𝟕 𝐏𝐫𝐢𝐦𝐢𝐭𝐢𝐯𝐞𝐬 (𝐈𝐦𝐦𝐮𝐭𝐚𝐛𝐥𝐞 & 𝐏𝐚𝐬𝐬-𝐛𝐲-𝐕𝐚𝐥𝐮𝐞) These are simple values. They don't have methods attached to them (until JS temporarily wraps them). • 𝐍𝐮𝐦𝐛𝐞𝐫: Integers & Floats. • 𝐒𝐭𝐫𝐢𝐧𝐠: Text. • 𝐁𝐨𝐨𝐥𝐞𝐚𝐧: True/False. • 𝐍𝐮𝐥𝐥: Intentionally empty. (The "I know this is empty" value). • 𝐔𝐧𝐝𝐞𝐟𝐢𝐧𝐞𝐝: Unintentionally empty. (The "I haven't set this yet" value). • 𝐒𝐲𝐦𝐛𝐨𝐥: Unique identifiers. • 𝐁𝐢𝐠𝐈𝐧𝐭: For numbers bigger than `2^53 - 1` (added in ES2020). 2️⃣𝐓𝐡𝐞 𝐑𝐞𝐟𝐞𝐫𝐞𝐧𝐜𝐞 𝐓𝐲𝐩𝐞𝐬 (𝐌𝐮𝐭𝐚𝐛𝐥𝐞 & 𝐏𝐚𝐬𝐬-𝐛𝐲-𝐑𝐞𝐟𝐞𝐫𝐞𝐧𝐜𝐞) • 𝐎𝐛𝐣𝐞𝐜𝐭: The parent of them all. • 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧: Yes, functions are objects! They are "callable" objects. • 𝐀𝐫𝐫𝐚𝐲𝐬: Special objects with numeric keys. 💡 𝐂𝐥𝐚𝐬𝐬𝐢𝐜 𝐉𝐒 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐐𝐮𝐞𝐬𝐭𝐢𝐨𝐧: Why does `typeof null` return `'object'`? 𝐴𝑛𝑠𝑤𝑒𝑟: It’s actually a bug from the very first version of JavaScript! It can't be fixed now without breaking the web, so we live with it. 😅 Check out the full list in the infographic below! 👇 How often do you actually use `Symbol` or `BigInt` in your day-to-day work? #JavaScript #WebDevelopment #CodingBasics #SoftwareEngineering #Frontend #JSFundamentals

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories