Skip to content

Instantly share code, notes, and snippets.

@Neophen
Created August 1, 2019 10:43
Show Gist options
  • Save Neophen/e313b954eb107deeb7b5583d4b3c360e to your computer and use it in GitHub Desktop.
Save Neophen/e313b954eb107deeb7b5583d4b3c360e to your computer and use it in GitHub Desktop.
let variable;
console.log(typeof variable); // undefined
variable = "1";
console.log(typeof variable); // string
variable = 2;
console.log(typeof variable); // number
variable = true;
console.log(typeof variable); // boolean
variable = {};
console.log(typeof variable); // object
variable = Symbol();
console.log(typeof variable); // symbol
//Some things to be aware of
console.log(typeof doesntExist); // is aldo undefined
variable = null;
console.log(typeof variable); // object, this is a javascript language bug
variable = function(){};
console.log(typeof variable); // function, while not a primite type it has it's own return type for the typeof operator
variable = [1,2,3];
console.log(typeof variable); // object, why for function and not array? Because of reasons :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment