Skip to content

PRO TIP Block youtube.com at the DNS level โ€” Pi-hole, NextDNS or your hosts file โ€” but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

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);