Shefali Profile picture
Jul 3, 2024 24 tweets 7 min read Read on X
JavaScript Objects🔥

Open this🧵 JavaScript Objects
💠Creating Objects

You can create objects in the following ways:
1⃣Object Literal

You can create an object using object literal i.e., curly braces. Image
2⃣Constructor Function

Using the 'new' keyword, the constructor function allows the creation of multiple objects. Image
3⃣Factory Function

Factory functions are functions that return objects.

You can create objects using factory functions. Image
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. Image
5⃣ES6 Class Syntax

You can use the 'class' keyword to define a constructor and methods for objects. Image
💠Object Properties Methods

1⃣Accessing Properties

You can access the properties of an object using dot notation or square brackets. Image
2⃣Modifying Properties

Objects are mutable, so you can modify the value of a property by assigning a new value to it. Image
3⃣Adding Properties

You can add new properties to an object as follows. Image
4⃣Checking the Presence of a Property

You can check if an object has a specific property using the following methods.

🔹hasOwnProperty method Image
🔹in operator Image
5⃣Deleting Properties

You can use the 'delete' operator to remove a property from an object. Image
6⃣Object.freeze()

You can use Object.freeze() method to prevent any changes to an object, including adding, modifying or deleting properties. Image
7⃣Object.seal()

You can use Object.seal() method to prevent adding or removing properties in the object. Image
8⃣Looping through Properties

You can loop through an object's properties using the following methods.

🔹for...in loop Image
🔹Object.keys

This method returns the array of keys of an object. Image
🔹Object.values

This method returns the array of values of an object. Image
🔹Object.entries

This method returns the array of key-value pairs of an object. Image
💠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. Image
💠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. Image
💠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. Image
You can read the full article here👇
shefali.dev/javascript-obj…
That's a wrap.

Thanks for checking out.

If you find this thread helpful, then consider:
❤️Like
✅Follow me @Shefali__J for more content like this.
🔁Repost the below quote 👇

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Shefali

Shefali Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Shefali__J

May 17
HTML Semantic vs. Non-Semantic Elements🔥

Open this🧵 Image
💠Semantic Elements

Semantic elements clearly show their purpose in the code and what content they hold. They make your web page more organized and have these benefits:

🔹Accessibility: Tools like screen readers can better understand and describe the content for users.

🔹SEO: Search engines can easily figure out your content and rank it higher.

🔹Readability: Your code is easier to understand and maintain for developers.

Examples of semantic elements:
,
,
,
Check out Learnify for more tutorials like this👇
learnify.shefali.dev
Read 7 tweets
Mar 31
18 JavaScript Tips for Clean and Efficient Code🔥

Open this🧵
1⃣Arrow Function

You can use arrow functions to simplify function declarations.

For example: Image
Subscribe to my newsletter🚀

Get the latest tips, tools, and resources to level up your web development skills, delivered straight to your inbox.

👉 Subscribe now: shefali.beehiiv.com/subscribe
Read 21 tweets
Mar 23
JavaScript DOM (Document Object Model)🔥

Open this🧵 JavaScript DOM (Document Object Model)
🎯What is the DOM?

DOM is a programming interface that allows us to select, modify, create, remove elements and manipulate element styles in the document.

DOM represents the structure of an HTML document as a tree-like structure. The document is the tree's root and contains one child node, the element.

Within the element, there are two children: the and elements. The and elements contain their respective children.Image
Subscribe to my newsletter🚀

Get the latest tips, tools, and resources to level up your web development skills, delivered straight to your inbox.

👉 Subscribe now: shefali.beehiiv.com/subscribe
Read 12 tweets
Mar 6
5 Websites Every CSS Developer Should Know🔥

Open this 🧵
🎯CSS-Tricks

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.devCSSnippets
Read 8 tweets
Feb 27
20 FREE APIs for Your Projects🔥

Open this🧵
🌦️OpenWeatherMap API

Provides real-time weather data, forecasts, and historical weather information for any location worldwide.
openweathermap.org
📰 News API

Allows you to fetch the latest news articles from thousands of news sources.
newsapi.org
Read 24 tweets
Feb 20
‘this’ in JavaScript: 10 Scenarios Simplified for Beginners🔥

Open this🧵
What is “this”?

In JavaScript, “this” is a special keyword that refers to the current execution context which means what is happening right now.

It changes its value depending on how a function is invoked.

So, let’s explore its different scenarios.
1⃣“this” in Global Context

When we use “this” in the global scope, then “this” refers to the global object.

For example, when we use “this” in a browser environment, then this is often the window object.

Now, what is window object?🤔

The window object represents that browser window which contains the document. This object provides properties and methods, by using them you can interact with the browser environment.Image
Read 17 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(