javascript value types code example
Example 1: check data type in javascript
typeof("string");
typeof(123);
Example 2: type javascirpt
console.log(typeof 42);
Example 3: javascript data types
var string = 'ASCII text';
var integer = 123456789;
var float = 123.456;
var t = true;
var f = false;
var undef;
var undef = undefined;
var nul = null;
var arr = ['Hello','my','name','is','Dr.Hippo',123,null];
var person = {'name':'John Smith','age':27};
var fun = function(){
return 42;
}
Example 4: javascript datatypes
dataTypes = {
Numbers = 1,2,3, 100, 3.14
Strings = 'Hello, World' "helloworld@gmail.com
Boolean = true / false
Null = 'Explicitly set a variable with no Value'
Undefined = 'For variable that have not yet been defined'
Object = 'Complex data structures - Arrays, Dates, Literals etc'
Symbol = 'Used with objects'
}
Example 5: data types in javascript
1, 1.0
'String', "String"
true, false
{id: 1;}
[1, 2, 3]