Mujeeb Ahmed Profile picture
Software Engineer 👨‍💻| Sharing AI Insights | Resources for Web Developers and AI Enthusiasts ✨

Mar 7, 2022, 11 tweets

JavaScript Objects 🔥🔥(Thread).

1. What is an Object in JavaScript?

The Object class represents one of JavaScript's data types. It's used to store keyed collections as well as more complex entities

2. How can you Create a JavaScript Object?

With JavaScript, you can define and create your objects.

There are different ways to create new objects:

1. Create a single object, using an object literal.

2. Create a single object, with the keyword new.

Using an Object Literal:

This is the easiest way to create a JavaScript Object.

Using an object literal, you both define and create an object in one statement.

An object literal is a list of name: value pairs (like name: "mujeeb") inside curly braces {}.

Example:

Using new keyword.
Example:

Using Object.create().
Example:

Accessing Properties of an Object.
The syntax for accessing the property of an object is:

Object Methods:
1. Keys.
2. values.
3. delete.
4. freeze.
1. keys:
The Object.keys() method produces an array of enumerable property names for a given object, iterated in the same way as a normal loop.

Example:

2. values:
The Object.values() method returns an array of enumerable property values for a given object in the same order as a for...in loop.

Example:

3. delete:
This method will remove the whole property from an array.

Example:

4. freeze:
An object is frozen using the Object.freeze() method. An object that has been frozen cannot be changed; Object.freeze() returns the same object that was passed in as an argument.

Example:

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling