JavaScript Object Definition

Methods for Defining JavaScript Objects

  • Using an Object Literal
  • Using the new Keyword
  • Using an Object Constructor
  • Using Object.assign()
  • Using Object.create()
  • Using Object.fromEntries()

JavaScript Object Literal

An object literal is a list of property names:values inside curly braces {}.

{firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};

Note:

An object literal is also called an object initializer.

Continue reading JavaScript Object Definition

JavaScript Math Object

The JavaScript Math object allows you to perform mathematical tasks on numbers.

Example

Math.PI;

The Math Object

Unlike other objects, the Math object has no constructor.

The Math object is static.

All methods and properties can be used without creating a Math object first. Continue reading JavaScript Math Object