JS is dynamically typed. You don't have to declare a type. types are determined automatically.
Values stored in variables have types, not the variables themselves.
console.log(typeof "word")
logs the type (in this case string)
typeof null
returns object. This is a legacy error.
creating a string without using quotes will give you an error. let string = this creates an error
logs "Uncaught SyntaxError: Unexpected identifier"
Objects
... coming soon
Primitives
There are 7 primitive data types in JavaScript
- numbers - floating point. Decimals and integers
- strings - characters
- boolean - true or false
- undefined - empty values
-
let name;
declaring a variable without assigning a value will have undefined as it's value
-
-
null - the intentional absence of any object value.
- falsy.
- symbol(ES2015) - guaranteed to be unique. Often used to add unique property keys to an object
- BigInt(ES2020) - for larger integers than number can handle
Top comments (0)