JavaScript Object Methods

General Methods

// Copies properties from a source object to a target object
Object.assign(target, source)

// Creates an object from an existing object
Object.create(object)

// Returns an array of the key/value pairs of an object
Object.entries(object)

// Creates an object from a list of keys/values
Object.fromEntries()

// Returns an array of the keys of an object
Object.keys(object)

// Returns an array of the property values of an object
Object.values(object)

// Groups object elements according to a function
Object.groupBy(object, callback)

JavaScript Object.assign()

The Object.assign() method copies properties from one or more source objects to a target object. Continue reading JavaScript Object Methods

JavaScript Date Objects

JavaScript Date Objects let us work with dates:

Mon Feb 24 2025 06:31:40 GMT+0330 (Iran Standard Time)

Examples

const d = new Date();

const d = new Date("2022-03-25");

 

Note

Date objects are static. The “clock” is not “running”.

The computer clock is ticking, date objects are not.

Continue reading JavaScript Date Objects

JavaScript Object Methods

JavaScript Object Methods

Object methods are actions that can be performed on objects.

A method is a function definition stored as a property value.

Property Value
firstName John
lastName Doe
age 50
eyeColor blue
fullName function() {return this.firstName + ” ” + this.lastName;}

Example

const person = {
  firstName: "John",
  lastName: "Doe",
  id: 5566,
  fullName: function() {
    return this.firstName + " " + this.lastName;
  }
};

In the example above, this refers to the person object :

this.firstName means the firstName property of person. Continue reading JavaScript Object Methods