Code Skiller logoCB Logo
Logo LearnLearnLogo PracticePracticeLogo HireHireLogo IDEIDE

Objects in JavaScript

User image

Published by

sanya sanya

Published at: 6th May, 2023
1.685 mins read

The objects in the javascript are something that has the properties and method. Let's take an example, everything we encounter in our day-to-day life is an object. For example, computers, mouse, and so on.

Such as in real life, In Javascript also everything is an object. Regular expressions, arrays, and functions, are always objects. However, Booleans, numbers, and strings can be objects.

All the values in the javascript except for the primitive data types values are objects.

Javascript Primitive Values

The Primitive Values are those values that have no properties and no methods. Moreover, Primitive Data Types are the data types that have primitive values.

There are seven Primitive values in Javascript mentioned below -

  1. String
  2. Number
  3. Boolean
  4. Null
  5. Undefined
  6. Symbol
  7. BigInt

One special thing about the primitive values is that these values are immutable and cannot be changed.

Creating an Object in Javascript

In javascript, we can define and create our objects. Several ways to create different Javascript Methods are as follows -

  1. By using an Object Literal, Create a single object. The code for the same is as follows -

  2. const person = {number: "one", name: "brock", age:50};

  3. Using the new keyword, create a single object.

  4. const obj = new Object(); obj.name = "Shivam"; obj.age = 25; obj.class = 10


  5. Using Object.create() to create an object
  6. First define an object constructor, and then create objects of the constructed types.
Objects in Javascript are mutable. Hence, we can perform some operations such as adding new items, deleting, and so on.

Properties Attributes

Several Properties Attributes supported by Javascript Object are as follows -

  1. All the properties have values and names
  2. The given value must be one of the property's attributes.
  3. Other attributes rather than the mentioned one are - enumerable, configurable, and writable.
  4. All the attributes define how can be the property writable or readable.
  5. The `value attribute` can be changed but not all the others.

Library

WEB DEVELOPMENT

Basic

HTML - Hyper Text Markup Language

CSS - Cascading Style Sheets

JavaScript

An Introduction to Javascript!

How to Run JavaScript Code

Variables in Javascript

Numbers in JavaScript

JavaScript Operators

Data Types in JavaScript

Conditional Statements

Switch Statements

Loops in Javascript

Arrays in JavaScript

Strings in JavaScript

Objects in JavaScript

Object Methods in JavaScript

Functions in JavaScript

Object Referencing and Copying in JavaScript

' this' keyword

Asynchronous Programming in JavaScript

Callbacks in JavaScript

Promises in JavaScript

Constructor Functions in JavaScript

Async and Await in JavaScript

Type Conversion in Javascript

DOM

Currying in JavaScript

Network Request

Frontend

Backend

Interview Questions

FAANG QUESTIONS

On this page

Javascript Primitive Values

Creating an Object in Javascript

Properties Attributes