Search the Blog

Wednesday, August 14, 2019

JavaScript datatypes syntax with demo code

typeof() - is the 'official' function that one uses to get the type in JavaScript, however in certain cases it might yield some unexpected results ...

1. Strings
typeof "String" or typeof Date(2011,01,01)

2. Number
typeof 42

3. Bool
typeof true (valid values true and false)

4. Object
typeof {} or
 typeof [] or
typeof null or
 typeof /aaa/ or
typeof Error()

5. Function
typeof function(){}

6. Undefined
var var1;
typeof var1


See also

Javascript Console opening in different browser
JavaScript Console methods and objects 
JavaScript Comments usage and sample example

No comments:

Post a Comment

Translate