Tell me about JavaScript 𝗽𝗿𝗶𝗺𝗶𝘁𝗶𝘃𝗲 𝘁𝘆𝗽𝗲𝘀: In JavaScript there are 7 primitive types: 𝗻𝘂𝗹𝗹, 𝘂𝗻𝗱𝗲𝗳𝗶𝗻𝗲𝗱, 𝘀𝘁𝗿𝗶𝗻𝗴, 𝗻𝘂𝗺𝗯𝗲𝗿, 𝗯𝗼𝗼𝗹𝗲𝗮𝗻, 𝘀𝘆𝗺𝗯𝗼𝗹, 𝗯𝗶𝗴𝗶𝗻𝘁. All primitive types are 𝗶𝗺𝗺𝘂𝘁𝗮𝗯𝗹𝗲, that is, they cannot be altered. They don't have methods, but they behave like they do. When properties are accessed on primitives, JavaScript 𝗮𝘂𝘁𝗼-𝗯𝗼𝘅𝗲𝘀 the value into a wrapper object. It makes possible to run some operations over the value, like 𝘁𝗼𝗙𝗶𝘅𝗲𝗱 in Number or 𝗰𝗵𝗮𝗿𝘁𝗔𝘁 in String. The object is discarded right after the operation completes. When passing a primitive value to a 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻, a copy of the value will be passed. This means that the original value and the value passed through the function have different space in memory. Use the comments if you have some addition or a simpler way to explain this. #javascript #techinterview #jobinterview #question #interviewquestion
Eric Santos’ Post
More Relevant Posts
-
"this" in JavaScript isn’t what you think it is. It doesn’t mean “this function”, it means “the object that called the function.” That’s why "this" changes depending on how the function is called. Arrow functions don’t have their own this. They inherit it from their parent scope, perfect for callbacks, but confusing inside classes and objects. That’s why in React or classes you often see .bind(this) in event handlers because without it, "this" gets lost when the function runs. So next time "this" is undefined, remember, It’s not you. It’s JavaScript being… JavaScript. #this #javascript
To view or add a comment, sign in
-
Deep JavaScript Series Have you ever seen your function run before it even exists? It's surprising, right? That’s **Hoisting** in action. JavaScript scans your file first, stores functions and variables in memory, and then runs the code. `var` appears as undefined, while `let` and `const` remain hidden in the temporal dead zone until they are declared. JavaScript doesn’t time travel; it just behaves like it does. #JavaScript #WebDev #Frontend #interview #inteviewTips
To view or add a comment, sign in
-
-
🚀 JavaScript Trick You Should Know! What do you think the result will be? 👇 "5" + 2 // ? "5" - 2 // ? ✅ "5" + 2 → "52" ✅ "5" - 2 → 3 Why? Because (+) combines strings, while (-) forces JavaScript to convert "5" into a number. A small example — but it shows how type coercion can completely change your output. ⚡ #JavaScript #FrontendDevelopment #CodingTips
To view or add a comment, sign in
-
📌How do call(), apply(), and bind() work in JavaScript, and when would you use each of them? ✨ My Thought Process: These three methods are used to explicitly set the value of this when invoking a function. 🔹 call() -Invokes the function immediately -Passes arguments individually func.call(thisArg, arg1, arg2); 🔹 apply() -Also invokes the function immediately -Passes arguments as an array func.apply(thisArg, [arg1, arg2]); 🔹 bind() -Returns a new function with this bound permanently -Does not execute the function immediately const newFunc = func.bind(thisArg); 💡 Use Cases: Borrowing methods across objects Event handlers with fixed context Delayed execution (with bind) 📌 Pro Tip: Prefer bind() for React event handlers to ensure the correct this context inside components. #JavaScript #InterviewQuestion #CallApplyBind #FrontendTips #100DaysOfFrontend
To view or add a comment, sign in
-
Understanding Map in JavaScript 💡 Why You Should Use Map Instead of Plain Objects Many developers still use objects for key-value pairs, but did you know JavaScript has a better alternative? Meet Map 👇 const userMap = new Map(); userMap.set("name", "Hemant"); userMap.set("age", 25); console.log(userMap.get("name")); // Hemant ✅ Advantages over objects: Keeps keys in insertion order Can use any type (even objects) as keys Has built-in methods: set(), get(), has(), delete(), and clear() If you’re still using plain objects for mapping, it’s time to level up 🚀 #JavaScript #WebDevelopment #CodingTips #Frontend
To view or add a comment, sign in
-
Lately, I’ve been revisiting some core JavaScript concepts, and today I stumbled upon something I hadn’t really paid attention to before — Symbols. They’re not something you see in everyday code, but I found them really interesting. A Symbol is a unique and immutable value that can be used as a key in objects. What I like about Symbols is that each one is completely unique, even if it has the same description: Symbol("id") === Symbol("id"); // false They can be super useful when you need unique property keys in an object — especially to avoid accidental overwriting. Even if I might not use them often, I enjoy discovering these little parts of JavaScript that make the language more powerful than it first seems. #JavaScript #WebDevelopment #LearningEveryDay
To view or add a comment, sign in
-
-
What is String Concatenation in JavaScript? String concatenation means joining two or more strings (text values) together into one string. Why it’s used We use string concatenation when we want to: Combine multiple pieces of text together Insert variable values inside text Example 1: let firstName = "Maruf"; let lastName = "Hossen"; let fullName = firstName + " " + lastName; console.log(fullName); Output: Maruf Hossen Example 2: let name = "Maruf"; let age = 25; let info = `My name is ${name} and I am ${age} years old.`; console.log(info); Output: My name is Maruf and I am 25 years old. #html #css #javascript #react #webdesign #webdeveloping
To view or add a comment, sign in
-
-
Daily JavaScript/React tip: Prefer async/await for clean, readable async code in JavaScript. In React, useEffect with a cleanup function helps prevent memory leaks when a component unmounts. Pro tip: keep effects focused and specify dependencies to avoid unnecessary re-runs. #JavaScript #React #WebDev
To view or add a comment, sign in
-
🚀 Day 36 — JavaScript Deep Dive: The this Keyword, Call, Apply & Bind Today, I explored one of the most confusing yet powerful concepts in JavaScript — the this keyword! 💡 Here’s what I learned: 🔹 this refers to the execution context — depends on how a function is called. 🔹 call() and apply() allow explicit binding of this. 🔹 bind() creates a new function with this permanently tied. 🔹 Arrow functions don’t have their own this — they use the surrounding scope’s context. Once it clicks, everything in JavaScript starts making more sense 🔥 Next → Closures & Scope Mastery! 🧠 #JavaScript #WebDevelopment #100DaysOfCode #LearningInPublic #SkillUpNation #FrontendDeveloper #CodingJourney #JavaScriptTips
To view or add a comment, sign in
-
-
Are you writing clean, high-performance JavaScript? 🚀 Stop making these common mistakes! This guide is packed with essential JS best practices to instantly level up your code quality and speed: -> Ditch var 🚫: Always use let and const to declare variables to prevent scope and redefinition errors. -> Optimize Loops ⏱️: Boost performance by reducing activity inside loops, like calculating array length once outside the loop. -> Minimize DOM Access 🐌: Accessing the HTML DOM is slow. Grab elements once and store them in a local variable if you need to access them multiple times. -> Use defer ⚡: For external scripts, use the defer attribute in the script tag to ensure the script executes only after the page has finished parsing. -> Meaningful Names ✍️: Use descriptive names like userName instead of cryptic ones like un or usrnm for better long-term readability. -> Be Thoughtful about Declarations 💡: Avoid unnecessary declarations; only declare when strictly needed to promote proper code design. Swipe and save these tips for cleaner, faster JS code! Which practice are you implementing first? 👇 To learn more about JavaScript, follow JavaScript Mastery #JavaScript #JS #WebDevelopment #CodingTips #Performance #CleanCode #DeveloperLife #TechSkills
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
... Primitives are allocated on stack.