JavaScript dynamic data types

Default variable type is string ie after declaration the data type is normally string or as most things are objects in JavaScript you can call it that way if you prefer to do so.

ie var name;
condole.log(typeof name) // string

null means a variable is declared but it still has nothing ie its null. null can also be used as a way to unset a variable's value.

Booleans values are true and false.
var on = true;
console.log(typeof on) // Boolean

objects and arrays in JavaScript are of type object ie an array is an object
var matrix = [[0, 1], [1, 0]]
var vector = {"x": 0, "y": 0}

console. log(typeof matrix) // Object
console. log(typeof vector) // Object

functions are also a special datatype
console. log(typeof  function(){}) // function


Popular posts from this blog

How to get user's ip address in JavaScript

How to make a static http server in nodejs using express

Array concat method in JavaScript

What is 'this.' keyword in JavaScript

How to create promises in JavaScript