check type javascript
> typeof "foo"
"string"
> typeof true
"boolean"
> typeof 42
"number"
if(typeof bar === 'number') {
//whatever
}typeof("string"); //string
typeof(123); //number//typeof() will return the type of value in it's parameters.
//some examples of types: undefined, NaN, number, string, object, array
//example of a practical usage
if (typeof(value) !== "undefined") {//asuming value is already set
//execute code
}if (typeof i != "number") {
console.log('This is not number');
}console.log(typeof "how are you?")
"string"
console.log(typeof false) / console.log(typeof true)
"boolean"
console.log(typeof 100)
"number"typeof operando
Also in JavaScript:
- jquery set width
- Javascript compare two objects
- javascript 2 decimal float array elements
- how to install node js in ubuntu
- what does json.parse do
- node js colors
- javascript detect click outside of element
- how to create a object in javascript
- import jquery into js file
- angular mouseenter
- jquery keyup
- generate 50 random numbers between 1 and 500 in javascript
- converting response in json
- how to comments in json file
- using fb login with angular app
- get client id socket io
- cannot use getidtoken if null
- How to insert an item into an array at a specific index JavaScript
- javascript fastest loop
- node.js crypto.createcipheriv
- kendo datetime picket default timezone
- on click move item top react
- js remove escape characters from json
- expressjs cheat sheet