1parseInt(value);
2
3let string = "321"
4console.log(string); // "321" <= string
5
6let number = parseInt(string);
7console.log(number) // 321 <=int
1// Method - 1 ### parseInt() ###
2var text = "42px";
3var integer = parseInt(text, 10);
4// returns 42
5
6// Method - 2 ### parseFloat() ###
7var text = "3.14someRandomStuff";
8var pointNum = parseFloat(text);
9// returns 3.14
10
11// Method - 3 ### Number() ###
12Number("123"); // returns 123
13Number("12.3"); // returns 12.3
14Number("3.14someRandomStuff"); // returns NaN
15Number("42px"); // returns NaN
1new Number(valeur);
2var a = new Number('123'); // a === 123 donnera false
3var b = Number('123'); // b === 123 donnera true
4a instanceof Number; // donnera true
5b instanceof Number; // donnera false