DEV Community

Jeevish
Jeevish

Posted on

Today, I spent time revising two essential core concepts in JavaScript:

JavaScript Objects and Arrow Functions. Here is a quick breakdown of what I covered:

​1. JavaScript Objects (Key-Value Pairs & Methods)

​Objects allow us to group related data and functionality together.

​Example 1: Mobile Object:

const mobile = {

brand: "Vivo",

price: 15000,

network: "5G",

browse: function () {

console.log("Browsing...");
Enter fullscreen mode Exit fullscreen mode

}

}

Example 2: Bike Objects (TVS & Bajaj):

const TVS = {

model: "XL-100",

price: 99000,

cc: 100,

drive: function () {

console.log("Speed - 70 km/h");
Enter fullscreen mode Exit fullscreen mode

}

}

const bajaj = {

model: "Pulsar",

price: 150000,

cc: 150,

drive: function () {

console.log("Speed - 120 km/h");
Enter fullscreen mode Exit fullscreen mode

}

}

2.Arrow Functions :

​Arrow functions provide a cleaner and shorter syntax for writing function expressions in JavaScript.

​Syntax:

(param1, param2) => expression;
Enter fullscreen mode Exit fullscreen mode

Example:

const add = (i, j) => i + j;

Top comments (0)