You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeof(1);// 'number'typeof(true)// 'boolean'typeof('hello')// 'string'typeof(function(){})// 'function'typeof({})// 'object'//this is controversial..some expect typeof(null) to return 'null'typeof(null)// 'object'typeof(undefined)// 'undefined'// its a number because its assumes some type of numerical operation went wrong but still a number was expectedtypeof(NaN)// 'number'
Common conversion types
//convert to stringletfoo=9foo.toString();// '9'//convert string to integerNumber.parseInt('8')// 8//this still works; as soon as a non-number is encountered, parsing stopsNumber.parseInt('859pod')// 859Number.parseInt('85u9pod')// 85Number.parseInt('799.90')// 799//however if you begin with a non-number, an error is thrownNumber.parseInt('ha4')// NaN - Not a Number//convert string to floatNumber.parseFloat('799.90')// 799.9