33 -1000 0
3.0 0.0001 -99.003
var num = 123; num.toString(); // returns string "123" (123).toString(); // returns string "123"
var success = false; // note that the value false is not in quotes. var answer = confirm("is this okay?"); // this will return a boolean alert(answer); // will print out true or false if(answer){ alert("you ARE ok"); } if(!answer){ // ! -- is the negation operator. It turns it into the opposite value alert("you are NOT ok"); }
//NaN: Not a Number Number.isNaN(3); // returns false Number.isNaN("boo"); // returns true Number.isInteger(123); // returns true Number.isInteger(123.4); // returns false //parseFloat() and parseInt() force conversion of a string into a number Number.parseFloat("21.4"); // returns 21.4 // if the first character in the string is a number, // it parses the string until it reaches the end of that number Number.parseFloat("76 trombones") // returns 76.0 Number.parseFloat("The magnificient 7"); // returns NaN Number.parseInt(18.95); // returns 18 Number.parseInt("12px"); // returns 12 Number.parseInt("1110"); // returns 1110 Number.parseInt("Hello"); // returns NaN // Swiss Army Knife for getting numerical values from other data types Number(true); // 1 Number(false); // 0 Number("123"); // 123 Number("horse"); // NaN