VIDEO 17 javascript
Tue Oct 29 2024 17:55:40 GMT+0000 (Coordinated Universal Time)
Saved by
@E23CSEU1151
////////////////**************OBJECTS part 2 IN JS **********////////////////////
////////// singleton objects
//const tinderuser = new Object()
const tinderUser ={} // assingning a function
tinderUser.id = "123abc" // putting value in function
tinderUser.name = "sammy " // putting value in function
tinderUser.isloggedin = false // putting value in function
console.log(tinderUser); // { id: '123abc', name: 'sammy ', isloggedin: false }
console.log(tinderUser.name); // sammy
/// nested functions
const regularuser ={
email: "some@gmail.com",
fullname: {
userfullname: {
firstname: "hitesh",
lastname: "sharma"
}
}
}
//console.log(regularuser);
console.log(regularuser.fullname.userfullname.firstname);/// hitesh
//// combining 2 objects together into a single object
const obj1 = { 1: "a" , 2: "b" }
const obj2 = { 3: "a" , 4: "b" }
const obj4 = { 5: "a" , 6: "b" }
//// assingnuing function
////const obj3 = Object.assign({}, obj1 , obj2 , obj4)
// syntax {} means target amd obj1 obj2 obj4 all three are source
/// drop function
//const obj5 = {...obj1, ...obj2, ...obj4};
//console.log(obj5);
/// methods inside arrays
const users = [
{
id: 1,
name: "tanishq dhingra "
},
{
id: 1,
name: "tanishq dhingra "
},
{
id: 1,
name: "tanishq dhingra "
}
]
console.log(users[1].id);
// function for getting the keys present in objects
console.log(Object.keys(tinderUser));
// function for getting the values present in objects
console.log(Object.values(tinderUser));
// function for getting the entries present in objects
console.log(Object.entries(tinderUser));
// function for checking properties present in objects and it will give answer in boolean
console.log(tinderUser.hasOwnProperty('isLoggedIn'));
content_copyCOPY
Comments