Data Types

  1. Number
  2. String
  3. booleans
  4. null
  5. undefined

Find the data types by using - typeof

Interesting thing - type of null is object - historical

Explaining difference between null and undefined

Explaining the difference between Primitives and Object - For primitives like number, string, booleans, etc if we copy it first and then change the copied one, then original remains unchanged while for object, it is changed.

//Example of Primitive
let money1 = 5000;
let money2 = money1;
money2 = 2000;
console.log(money1);
console.log(money2);

//Example of object
const student1 = {name: "Ram"};
const student2 = student1;
student2.name = "Shyam";
console.log(student1);
console.log(student2);

If Else

if(age >= 16) {
    console.log("You can drive");
} else {
    console.log("You cannot drive");
}

What is truthy and falsy(0, “”, false, null, undefined, NaN,) value and using it in if else.

Task -

  1. Imagine a lift where a person with weight more than 120 kg is forbidden, Make an if else for it.
  2. Check if the user is eligible to vote (age ≥ 18).
  3. Check if a number is positive or negative.
  4. Check if a number is odd or even.