DEV Community

Cover image for Getting Started: Easy Way to Objects in JavaScript

Posted on

Getting Started: Easy Way to Objects in JavaScript

Almost Everything in JavaScript are objects, ranging from functions to object itself etc, except the primitive values.
Even some primitive values when called with the ‘new’ keyword will still return an object.

Math, RegExp, Date, function are all objects,
with the new keyword string, number, Boolean will also return an object.

In JavaScript objects controls almost everything, objects is the main route, the emperor of JavaScript, if you understand how objects works in and out, there’s chances you will understand how JavaScript works.

what are primitive values ?
Primitive values are values with no property and methods, In JavaScript Primitive values are not objects, they are immutable and hard coded value, which can’t be change.

Example of primitive values in JavaScript are string, numbers, Boolean, null, and undefined.

Let name = ‘John Doe’

Primitive data types
Are data that has a primitive value.

What are objects
Let take a glance through variables in JavaScript,
const pie = 3.14

JavaScript variable can only contain a single value, in this example the only value is 3.14, Objects are also variables.

Objects are variables that can contain more than one value, basically a collection of named values


Top comments (0)