js_programming-14-06-2024-1
js_programming-14-06-2024-1
NITHIN
nithin@pentagonspace.in
The + operator
The ‘+’ operator works differently for numbers and strings. For
numbers, the operator performs mathematical addition whereas for
strings, it performs concatenation
Try It Yourself –
let x = 10 + 20;
let x = 10 + “20”;
let x = “10” + 20;
let x = 10 + 20 + “30”;
let x = “10” + 20 + 30;
let x = “Hello” + “world”;
Eg –
let x = 2 / 0;
let y = -2 / 0;
Solutions:
array_name[0]
array_name[array_name.length - 1]
For of loop
const cars = ["BMW", "Benz", "Mini Cooper", "Audi"];
const student = {
firstName: "Suraj",
lastName: "S",
age: 10,
};
Because of this,
We can still change the elements of the array even on using const.
.map()
Creates a new array by invoking a callback on each element.
It skips array elements without values.
Does not change the original array.