js int code example

Example 1: intval js

parseInt(value);

let string = "321"
console.log(string); // "321" <= string

let number = parseInt(string);
console.log(number) // 321 <=int

Example 2: Javascript string to int

var myInt = parseInt("10.256"); //10
var myFloat = parseFloat("10.256"); //10.256

Example 3: javascript int values

var min = parseInt("2");
var max = parseInt("3");

Example 4: javascript type casting int

Number("3.14") // returns 3.14
false.toString()   // returns "false"
String(false)      // returns "false"

Example 5: hex string to int javascript

console.log(hex.toString(16));

Example 6: js int

var myInt = 69420

1+1//int
1+"1"//string

Tags:

Php Example