Show Menu
Cheatography

JavaScript Object Cheat Sheet (DRAFT) by

Javascript Object Cheatsheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Javascript Object Definition

Booleans can be objects (if defined with the new keyword)
Numbers can be objects (if defined with the new keyword)
Strings can be objects (if defined with the new keyword)
Dates are always objects
Maths are always objects
Regular expres­sions are always objects
Arrays are always objects
Functions are always objects
Objects are always objects
In JavaSc­ript, almost "­eve­ryt­hin­g" is an object.
All JavaScript values, except primit­ives, are objects.

7 Types JavaScript Primitives

string
number
boolean
null
undefined
symbol
bigint
A primitive value is a value that has no properties or methods.
3.14 is a primitive value
A primitive data type is data that has a primitive value
 

Creating a JavaScript Object

Create a single object, using an object literal.
'const person = {first­Nam­e:"J­ohn­", lastNa­me:­"­Doe­", age:50, eyeCol­or:­"­blu­e"};'
Create a single object, with the keyword new.
Define an object constr­uctor, and then create objects of the constr­ucted type.
Create an object using Object.cr­eate().