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...");
}
}
Example 2: Bike Objects (TVS & Bajaj):
const TVS = {
model: "XL-100",
price: 99000,
cc: 100,
drive: function () {
console.log("Speed - 70 km/h");
}
}
const bajaj = {
model: "Pulsar",
price: 150000,
cc: 150,
drive: function () {
console.log("Speed - 120 km/h");
}
}
2.Arrow Functions :
Arrow functions provide a cleaner and shorter syntax for writing function expressions in JavaScript.
Syntax:
(param1, param2) => expression;
Example:
const add = (i, j) => i + j;
Top comments (0)