You can create an object using object literal i.e., curly braces.
2⃣Constructor Function
Using the 'new' keyword, the constructor function allows the creation of multiple objects.
3⃣Factory Function
Factory functions are functions that return objects.
You can create objects using factory functions.
4⃣Object.create()
Using Object.create() method, you can create a new object using an existing object as the prototype for the newly created object.
5⃣ES6 Class Syntax
You can use the 'class' keyword to define a constructor and methods for objects.
💠Object Properties Methods
1⃣Accessing Properties
You can access the properties of an object using dot notation or square brackets.
2⃣Modifying Properties
Objects are mutable, so you can modify the value of a property by assigning a new value to it.
3⃣Adding Properties
You can add new properties to an object as follows.
4⃣Checking the Presence of a Property
You can check if an object has a specific property using the following methods.
🔹hasOwnProperty method
🔹in operator
5⃣Deleting Properties
You can use the 'delete' operator to remove a property from an object.
6⃣Object.freeze()
You can use Object.freeze() method to prevent any changes to an object, including adding, modifying or deleting properties.
7⃣Object.seal()
You can use Object.seal() method to prevent adding or removing properties in the object.
8⃣Looping through Properties
You can loop through an object's properties using the following methods.
🔹for...in loop
🔹Object.keys
This method returns the array of keys of an object.
🔹Object.values
This method returns the array of values of an object.
🔹Object.entries
This method returns the array of key-value pairs of an object.
💠Nested Objects
If you create an object, in which, an object is used as a value of the object, then this refers to a nested object.
This is used for organizing and structuring complex data hierarchies.
💠Object Destructuring
Object destructuring in JavaScript is a way to extract specific properties from an object and assign them to variables.
It's a handy shortcut that lets you access object properties without typing out long dot notation every time.
💠Object Spread Operator
If you want to create an object by copying the properties of an existing object and adding or modifying properties as needed, then you can use the spread '...' operator.
10 GitHub Repositories You Should Know as a Developer🔥
Open this🧵
Bookmark for later🔖
🔹Web-Dev-Resources
A collection of free web development resources, including APIs, hosting platforms, cheat sheets, icons, templates, fonts, color tools, learning platforms, and more. github.com/WebdevShefali/…
🔹Public APIs
A collection of free and public APIs for use in software and web development projects. github.com/public-apis/pu…
CSS-Tricks is one of the best resources for learning CSS. It was created by web designer Chris Coyier and is filled with tutorials, tips, and guides that help developers at any skill level. css-tricks.com
🎯CSSnippets
CSSnippets is a collection of useful code snippets for HTML, React, CSS, and Tailwind CSS. It has ready-made code for things like buttons, box-shadows, cards, checkboxes, dropdowns, and more. Developers can quickly copy these snippets. cssnippets.shefali.dev