DEV Community

stalin s
stalin s

Posted on

JavaScript Objects

In this blog , we will be exploring what are JavaScript objects and its declarations.

What are Objects🤔??.

An object is data that contains key-value pairs within curly braces.

example:

const anObject = {
  key1: 'value1',
  key2: 'value2',
  key3: 'value3',
  // ...
}
Enter fullscreen mode Exit fullscreen mode

Point to be noted : key gives references to a value.

Let's take one real life example of macbook:

const macbook = {
  operatingSystem: 'macOS Sierra',
  screenResolution: '2880x1800',
  screenSize: '15.4 inch',
  usbPorts: 2,
  storage: '512gb',
  // ... Other specs
}
Enter fullscreen mode Exit fullscreen mode

Getting the value of a property.

what are properties in javaScript??

Object keys
are called properties.
example : operatingSystem of macbook.

So we use two method to fetch value of a property.

dot notation

const prop = object.property

bracket notation

const prop = object[property]

Happy Learning

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series đź“ş

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series đź‘€

Watch the Youtube series

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay