Skip to content

Commit b83608b

Browse files
committed
02 basics / 05 Objects and JSON Api Intro
Learned about Destructuring objects and had a intro of JSON, API.
1 parent 0823058 commit b83608b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

02_Basics/05_object_json.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// 5. De-Structuring Object,
2+
3+
/* Destructuring objects in JavaScript is a convenient way to extract properties
4+
from objects and assign them to variables. This syntax simplifies accessing data
5+
within objects and helps you write cleaner and more readable code. */
6+
7+
const course = {
8+
courseName: "Learn Javascript",
9+
price: "Free",
10+
courseInstructor: "Ayush"
11+
}
12+
// const {courseInstructor, price} = course
13+
const {courseInstructor: instructor} = course
14+
console.log(instructor); // Output: Ayush
15+
16+
/*--------------------------------------------------------------------------------
17+
JSON (Javascript Object Notation),
18+
API can provide data in a structured format such as JSON,
19+
JSON's structure is easy for humans to read and understand,
20+
21+
{
22+
"name": "Ayush",
23+
"courseName": "JS Hindi",
24+
"price": "Free"
25+
}
26+
27+
The given JSON data is an array of three empty objects,
28+
29+
[
30+
{},
31+
{},
32+
{}
33+
]
34+
*/

0 commit comments

Comments
 (0)