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

Comments

Popular posts from this blog

JavaScript introduction to variables

JavaScript intro to classes

Tar basic commands to store and extract files

Snake monochrome (JS1024)

How to resume a suspended web audio api context