avatarKirti K

Summary

The provided web content outlines the ninth day of a 100-day JavaScript interview preparation journey, focusing on primitive and non-primitive data types in JavaScript.

Abstract

The web content is part of a series titled "100 Days of JavaScript Interview Prep: A Beginner’s Journey," specifically documenting Day 9. It delves into the fundamental concepts of JavaScript data types, distinguishing between primitive and non-primitive data types. The article explains that JavaScript has seven primitive data types: Number, String, Boolean, Null, Undefined, Symbol, and BigInt. These primitives are immutable and are passed by value. In contrast, non-primitive data types, such as Objects (including arrays and functions), are mutable, passed by reference, and can vary in size. The content serves as a guide for interview preparation, emphasizing the importance of understanding these data types for aspiring JavaScript developers.

Opinions

  • The author, Kirti Kaushal, values the sharing of knowledge and encourages respectful interactions within the learning community.
  • The article implies that mastering the basics of JavaScript, including data types, is crucial for interview success.
  • The author suggests that consistent practice, as demonstrated by the 100-day journey, is a effective method for learning and retaining information.
  • The use of examples and the encouragement of subscriptions and claps indicate that the author appreciates engagement and support from readers.
  • The inclusion of previous days' links implies a structured approach to learning, with each day building upon the last.

JavaScript Day 9 — Mastering JavaScript Basics: A Comprehensive Guide for Interview Preparation

100 Days of JavaScript Interview Prep: A Beginner’s Journey

Welcome to Day 9–100 Days of JavaScript Interview Prep: A Beginner’s Journey

DAY 9 (March 31, 2024) — Primitive and Non-primitive Data Types Interview Questions — Kirti Kaushal

Join us as we document a 100-day adventure filled with learning, practice, and growth.

DAY 9 (March 31, 2024) —Primitive and Non-primitive Data Types Interview Questions

Question 1 : What are primitive data types in JavaScript?

Answer:

A primitive (primitive value, primitive data type) is data that is not an object and has no methods or properties.

There are 7 primitive data types

All primitives are immutable; that is, they cannot be altered

Number: let num = 10;
String: let str = "Hello";
Boolean: let bool = true;
Null: let nullValue = null;
Undefined: let undefinedValue;
Symbol: let sym = Symbol("foo");
BigInt

Question 2: Differentiate between primitive and non-primitive data types in JavaScript, with examples?

Answer

Primitive data types

  • Primitive data types are immutable and stored directly in the variable, while non-primitive data types are mutable and stored by reference.
  • Primitive values are stored directly in the variable’s memory location.
  • Primitive Data Types: Passed by value. When passing a primitive value to a function, a copy of the value is passed.
  • Primitive Data Types: Typically smaller and fixed.

Example of primitive type:

Primitive Data Types: Number, String, Boolean, Null, Undefined, Symbol.

let num = 10;
let str = "Hello world";

Non-primitive data types

  • Non-primitive data types are mutable.
  • They can be modified after creation.
  • Non-primitive values are stored by reference.
  • Variables hold references (memory addresses) to the actual object stored in the heap
  • Non-Primitive Data Types: Object (including arrays, functions, and other objects).
  • Non-Primitive Data Types: Passed by reference. When passing a non-primitive value to a function, the reference to the original value is passed.
  • Non-Primitive Data Types: Can vary in size based on the contents of the object and are dynamically resizable.
let employee= { name: "tommy", age: 23 };
let myNumbers= [1, 2, 3,4,5];

Kind is cool !!! Share knowledge to gain knowledge !!!! Be kind and treat people with respect !!

If you find my videos helpful, then please subscribe, Claps and follow to support

Cheers

Kirti Kaushal

Coding Interviews
JavaScript
Javascript Interview
Coding For Kids
Programming
Recommended from ReadMedium