1parseInt(value);
2
3let string = "321"
4console.log(string); // "321" <= string
5
6let number = parseInt(string);
7console.log(number) // 321 <=int
1var myInt = parseInt("10.256"); //10
2var myFloat = parseFloat("10.256"); //10.256
1// parseInt
2parseInt("10");//------------ 10
3parseInt("10.00");//--------- 10
4parseInt("10.33")//--------- 10
5parseInt("34 45 66")//------ 34
6parseInt(" 60 ")//------ 60
7parseInt("40 years")//------ 40
8parseInt("He was 40")//----- NaN
9parseInt("10", 10)//-------- 10
10parseInt("010")//----------- 10
11parseInt("10", 8)//--------- 8
12parseInt("0x10")//---------- 16
13parseInt("10", 16)//-------- 16
14// parseFloat
15parseFloat("10")//-----------10
16parseFloat("10.00")//--------10
17parseFloat("10.33")//--------10.33
18parseFloat("34 45 66")//-----34
19parseFloat(" 60 ")//---------60
20parseFloat("40 years")//-----40
21parseFloat("He was 40");//----NaN
22/ mm.mirzaei /
1// ParseInt
2var myInt = parseInt("10.256"); //10
3parseInt("10");//------------ 10
4parseInt("10.00");//--------- 10
5parseInt("10.33")//--------- 10
6parseInt("34 45 66")//------ 34
7parseInt(" 60 ")//------ 60
8parseInt("40 years")//------ 40
9parseInt("He was 40")//----- NaN
10parseInt("10", 10)//-------- 10
11parseInt("010")//----------- 10
12parseInt("10", 8)//--------- 8
13parseInt("0x10")//---------- 16
14parseInt("10", 16)//-------- 16
15
16// parseFloat
17parseFloat("10")//-----------10
18parseFloat("10.00")//--------10
19parseFloat("10.33")//--------10.33
20parseFloat("34 45 66")//-----34
21parseFloat(" 60 ")//---------60
22parseFloat("40 years")//-----40
23parseFloat("He was 40");//----NaN
24var myFloat = parseFloat("10.256"); //10.256
1var myInt = parseInt("12.345");
2//myInt = 12
3
4var myFloat = parseFloat("12.345");
5//myFloat = 12.345
6
7var myFloat = parseFloat("12.345,50"); //<-- pay attention!
8//myFloat = 12.345
9
10var myFloatCrazy = parseFloat(0.1+0.2); //<-- pay MORE attention!
11//myFloat = 0.30000000000000004
12