0 points

The valueOf() Method - Returns number of mathematical expression or number variable


dashboard

Tue Jan 07 2020 19:00:00 GMT+0000 (UTC)

Posted by @goblindoom95 #javascript #jsfunctions #numbers

var x = 1234;
var y = x.valueOf(); 

var y = (1234).valueOf();

var y (1000+234).valueOf();

//y equals 1234 in all 3 cases
content_copy Copy

Lines 1-2: variable y gets number value of variable x Line 4: variable y gets value of the number 1234 line 6: variable y gets value of the mathematical expression: 1000+234