Skip to content

JavaScript Reference: Object

All about the JavaScript Object properties and methods

This post documents all the Object built-in object properties and methods.

Any value that’s not of a primitive type (a string, a number, a boolean, a symbol, null or undefined) is an object. Even arrays or functions are, under the hoods, objects.

An object value can be generated using an object literal syntax:

const person = {}
typeof person //object

using the Object global function:

const person = Object()
typeof person //object

or using the Object constructor:

const person = new Object()
typeof person //object

Another syntax is to use Object.create():

const car = Object.create()

You can initialize the object with properties using this syntax:

const person = {
  age: 36,
  name: 'Flavio',
  speak: () => {

const person = Object({
  age: 36,
  name: 'Flavio',
  speak: () => {

const person = new Object({
  age: 36,
  name: 'Flavio',
  speak: () => {

All those ways are basically equivalent as they all give you access to the methods I’ll list below.

You can also initialize an object using the new keyword before a function with a capital letter. This function serves as a constructor for that object. In there, we can initialize the arguments we receive as parameters, to setup the initial state of the object:

function Car(brand, model) {
  this.brand = brand
  this.model = model

We initialize a new object using

const myCar = new Car('Ford', 'Fiesta')
myCar.brand //'Ford'
myCar.model //'Fiesta'

Objects have properties. Every property has a name and a value.

You might think an object is basically a map, or dictionary, data structure, and you would be correct.

The value of a property can be of any type, which means that it can even be an object, as objects can nest other objects.

When a property value is a function, we call it method.

Objects can inherit their properties from other objects, and we’ll see this in details when we’ll talk about inheritance.

Objects are always passed by reference.

If you assign a variable the same value of another, if it’s a primitive type like a number or a string, they are passed by value:

let age = 36
let myAge = age
myAge = 37
age //36
const car = {
  color: 'blue'
const anotherCar = car
anotherCar.color = 'yellow'
car.color //'yellow'

Built-in Object Properties

The Object object has 2 properties

Static methods

We divide methods in static methods, and instance methods. Static methods are called directly on Object. Instance methods are called on an object instance (an object).

Static methods are a great way to offer a namespace for functions that work in the same space. In this way we don’t have global functions around, but all are namespaced under the Object global object.

Instance methods

→ Download my free JavaScript Handbook!



You might be interested in those things I do:

  • Learn to code in THE VALLEY OF CODE, your your web development manual
  • Find a ton of Web Development projects to learn modern tech stacks in practice in THE VALLEY OF CODE PRO
  • I wrote 16 books for beginner software developers, DOWNLOAD THEM NOW
  • Every year I organize a hands-on cohort course coding BOOTCAMP to teach you how to build a complex, modern Web Application in practice (next edition February-March-April-May 2024)
  • Learn how to start a solopreneur business on the Internet with SOLO LAB (next edition in 2024)
  • Find me on X

Related posts that talk about js: