-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile42.js
More file actions
33 lines (27 loc) · 850 Bytes
/
Copy pathfile42.js
File metadata and controls
33 lines (27 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
// object inside array
// very usefull in real time world applications
// let's see patten first
// variable variableName = [{} , {} , {} ]
const users = [
{userId : 1 ,firstName :" jitendra",gender : "male" },
{userId : 2 ,firstName :" ankit",gender : "male" },
{userId : 3 ,firstName :" punit",gender : "male" },
]
// iterating the values for of loop
// for(const user of users){
// console.log(user);
// console.log(`${user.userId} : ${ user.firstName} `);
// }
// using for in loop
// for(const index of users){
// console.log(index.firstName);
// }
// let's try with for loop
let newUserData = [] ;
for(let i =0; i <= users.length-1;i++ ){
// newUserData = users[i];
newUserData = users[i].userId
let newUserData2 = users[i]["firstName"];
console.log(newUserData + " : "+ newUserData2 );
}