//from a value to a number
let x = '222';
let number1 = x-0;
console.log(number1);
let number2 = +x;
console.log(number2);
let number3 = Number(x);
console.log(number3);
//from a value to a string
let string1 = x + "";
console.log(string1);
let string2 = String(x);
console.log(string2);
// a value to a boolean
let bool1 = !!x;
console.log(bool1);
let bool2 = Boolean(x);
console.log(bool2);
输出结果:
222
222
222
222
222
true
true