Learn JavaScript TYPE CONVERSION in 5 minutes! ๐ฑ
108.5K views on YouTube
// type conversion = change the datatype of a value to another
// (strings, numbers, booleans)
// ————— EXAMPLE 1 —————
let age = window.prompt(“How old are you?”);
age = Number(age);
age+=1;
console.log(age, typeof age);
// ————— EXAMPLE 2 —————
let x = “pizza”;
let y = “pizza”;
let z = “pizza”;
x = Number(x);
y = String(y);
z = Boolean(z);
console.log(x, typeof x);
console.log(y, typeof y);
console.log(z, typeof z);