Blog

Object

JS

Object short-hand

concize and cute syntax

Ragav Kumar V

Ragav Kumar V

Aug 20, 2022 ยท 1 min read

Key name & value name must be same


_8
const age = 20;
_8
const stream = "Aeronautical";
_8
_8
const student = {
_8
name: "APJ",
_8
age: age,
_8
stream: stream,
_8
};


_5
const student = {
_5
name: "APJ",
_5
age,
_5
stream,
_5
};

If the keys & value are not same like score & mark then you have mention both otherwise it will Result in error


_9
const age = 20;
_9
const stream = "Aeronautical";
_9
const mark = 90;
_9
const student = {
_9
name: "APJ",
_9
age,
_9
stream,
_9
score: mark,
_9
};


_9
const age = 20;
_9
const stream = "Aeronautical";
_9
const mark = 90;
_9
const student = {
_9
name: "APJ",
_9
age,
_9
stream,
_9
score,
_9
};

@ragavkumarv
swipe to next โžก๏ธ