Answer for 3:28 , I have used in my coding with help of phones instead of laptop. let alien = { name : 'Chandramouli', tech : 'Javascript', phones : { android_version : '11', ram : '4', brand1 : 'mi' } } for(let key in alien.phones) { console.log(key, alien.phones[key]); } Output : android_version 11 ram 4 brand1 mi
@teenskeey21572 жыл бұрын
Nice one🙌
@muhidshaikh6446 Жыл бұрын
☻
@kolaraju8114 Жыл бұрын
Thank you
@apoorv14412 жыл бұрын
to get keys of laptop key : for(let key in alien.laptop){ console.log(key) } to get values of laptop keys : for(let key in alien.laptop){ console.log(alien.laptop[key]) } //Alternative for(let key in alien["laptop"]){ console.log(key) }
@almajose43969 ай бұрын
M
@SalmanulFaris-zv6qy5 ай бұрын
this will only print the values of properties eg: i7,4, asus
@WenboWang-u8b2 күн бұрын
for(let key in alien['laptop']){ console.log(key, alian['laptop'][key]) }does it work.
@muskangupta680 Жыл бұрын
let Employee={ name:"Muskan", age:22, course:{ main_subjects:'Mathematics', 'minor subject':'English'} }; for (let key in Employee.course){ console.log(key,Employee.course[key]); } output:- main_subjects Mathemaics minor subject English
@bonnyrogny241 Жыл бұрын
its correct😶
@kheiromahiout7483 Жыл бұрын
The answer of 3.38 is: For(let key in alien["laptop"]{ Console.log(key, alien.laptop[key])}
@sandeepprabhakula77143 жыл бұрын
for(let key in alien.laptop){ console.log(key,alien.laptop[key]); } I think it should work
@santoshsuryavamshi8883 жыл бұрын
Good it's working.
@sshreeeditz6403 жыл бұрын
Its working. Spr👏
@nocontentshere81163 жыл бұрын
for(let key in alien){ console.log(key,alien.laptop.key); } might think this will also work. and in for don't need to denote the inside object, can directly take whole object
@sandeepprabhakula77143 жыл бұрын
@@nocontentshere8116 yes it will work
@tomasmatusek62923 жыл бұрын
waw
@adithya15779 ай бұрын
At 3:28 let alien = { name :'Adithya', language: 'JS', exp :'Fresher', laptop : { cpu : 'i3', ram : '4', brand : 'hp' } } for (key in alien.laptop){ console.log(key,alien.laptop[key]); }
@mdirfanmullick3 жыл бұрын
Very nice series, Navin. I binge watched it in 2 hours it was so exciting ☺️ please keep it on. Waiting for the next one
@deepalibiradar36842 жыл бұрын
Your teaching technique is really adorable...you made my day... 🤩 A million thanks to you ❤️🙏
@Excel-zu5iv2 жыл бұрын
I came back from the last video, here is my shortcut code: (it works even if the object has multiple objects in it): function key_printer(obj, spaces = '') { for(keys in obj) { if(typeof obj[keys] != 'object') { console.log(spaces + keys); } else { console.log(spaces + keys); key_printer(obj[keys], spaces + ' ') } } } key_printer(objects) //Note: The word 'objects' is the object name. This works...
@DesiVillagerEurope10 ай бұрын
Oh why did i see this only now . Great teacher . Great sir
@lathavoggu26393 жыл бұрын
3:31 for( let key in alien){ if( typeof (alien[key]) === 'object') { for(let key1 in alien[key]){ console.log(key1, alien[key][key1]); } }else console.log(key, alien[key]); }
@__________________________69103 жыл бұрын
Great
@blackpanther-vr6yj3 жыл бұрын
Thanks
@maverick_8707 Жыл бұрын
to print the value of the object we can do this for (const key in alien) { if (Object.hasOwnProperty.call(alien, key)) { const element = alien[key]; console.log(element); } }
@shivampathak1405 Жыл бұрын
Answer for 3:28 || for (key in alien.laptop) { console.log(key, alien.laptop[key]) }
@omatsoladev3 жыл бұрын
thanks so much Navin, i am loving the series , i took your python course and i enjoyed it. you know how to simplify everything to make it possible for us to learn. thank you so much
@yazor87163 жыл бұрын
for (let key in alien) { if (typeof alien[key] === "object") { for (let key2 in alien[key]) { console.log(key2, alien[key][key2]) } } else console.log(key, alien[key]) } I run it, it works :) Edit: I might have misunderstood the objective. Not sure if we were supposed to print the inner object's properties only. In any case, this program prints the properties of both objects.
@bhumit0703 жыл бұрын
yes it is okay, but better to wrap it inside function you can see my comment
@yazor87163 жыл бұрын
@@bhumit070 I am assuming you made it recursive so that it can print multiple nested objects, right? Good thinking!
@tomasmatusek62923 жыл бұрын
realy good waw.Something like that I was try find, u are good.
@tomasmatusek62923 жыл бұрын
that is realy perfect and is interesting that if you dont use alien[key],only alien[key2]it not work good, so you must use alien[key][key2], that is realy interesting. And same thanks for this else, realy good if we dont have objects in laptops, GJ bro.
@tomasmatusek62923 жыл бұрын
can you share with me where you get the idea about key1 and key2?
@gbolahanalaba8 ай бұрын
To print only laptop for(let key in alien.laptop) console.log(key, alien.laptop[key])
let cs = { student:"Datta Sai", subjects:"ui design", profesors:{ui_design_class:"Andrue",intro_to_networking_class:"Ajay"} } for(let key in cs){ console.log(key,cs[key]) } for(let key1 in cs.profesors){ console.log(key1,cs.profesors[key1]) }
@sprinter5901 Жыл бұрын
Answer for 3:28 Can be a bit overwhelming for beginners: let alien = { name: "Navin", tech: "JS", laptop:{ cpu: "i7", ram: 4, brand: "asus" } } for(let key in alien){ switch(key){ case"laptop": for(let key2 in alien["laptop"]){ console.log(key2, alien["laptop"][key2]); } default: if(key === "laptop"){ break; } else{ console.log(key, alien[key]); } } }
@gowthammanikandan25633 жыл бұрын
The main thing I learnt from you was. Learn How to learn.😇
@gobinathpalanisamy5450 Жыл бұрын
When can handle multiple inner objects by the following example program let alien={ name:"gobi", role:"lead", laptop:{ brand1:"mac", version:"pro" }, loc:"chennai" } for(let key in alien){ value= alien[key]; if (typeof value== "object") { for(let innerkey in value) { console.log( key, innerkey, value[innerkey]) } } else{ console.log( key, alien[key]) } }
for (const i in alien.laptop) { console.log(i+" -> "+alien.laptop[i]); } Love Telusko Learning ❤️
@vinykp5128 Жыл бұрын
let Employee={ name:'vinayak', native:'haveri', collage:{ collage_name:'GECK', Branch:'mech' } } for(let key in Employee.collage){ console.log(key,Employee.collage[key]); } ------output is ----- collage_name GECK Branch mech
@gandamraviteja7019 Жыл бұрын
for(let key in alien.laptop){ console.log(key,alien.loptop[key]); } console.log("Done myAlien"); Thank you for helping us to grow❤
@prasad4you57s23 жыл бұрын
let prasad = { name : 'prasad', age : 30, laptop: { ram : 200, brand1:'asus' } } for(let key in prasad){ console.log(key, prasad[key]) if(key==='laptop'){ for(let n in prasad[key]){ console.log(n, prasad[key][n]) } } }
@emrandavid4851 Жыл бұрын
3:28 thsi is the easiest way to print out let data ={ name:'emran', grade:12, sex:'m', //another dict for laptops laptop:{ brand:'hp', ram:16, cpu:'r9', } } for (let key in data.laptop) { console.log(key,data.laptop[key]) }
@dheerajg1478 ай бұрын
3:28 answer let aliean = { name : 'navin', tecj: 'js', 'work exp' : 5, laptop : { cpu : 'i7', ram : 4, brand : 'asus' } } for (let key in aliean.laptop) { console.log(key, aliean.laptop[key]); }
@PraveenKumar-sk5sd3 жыл бұрын
a={ name:'praveen', department:'ECE', NCC:{ drill:'good', comm:'excellent' } } for(let as in a) { console.log(as,a[as]) } for(let i in a['NCC']) { console.log(i,a['NCC'][i]) }
@UmeshchandrareddyGS2 жыл бұрын
Bro channel Peru adhirindhi😊🥰 thelsukunnaaaaam bro👍🤝
@mdzaid64223 жыл бұрын
for(let key in alien){ if(key == 'laptop'){ for (const key in alien.laptop) console.log(key,alien.laptop[key]) } else console.log(key, alien[key]); }
@tsa_vibes3 жыл бұрын
for(let key in alien['laptop']) { console.log(key, alien.laptop[key]); } output: cpu i7 ram 4 brand Asus
@RAVISINHA-jd9wq3 жыл бұрын
For ( key in alien[laptop.key] ) Console. Log( key )
@patelronak1533 жыл бұрын
for(key in alien.laptop){ console.log(key, alien.laptop[key]) }
@rayanjames3050 Жыл бұрын
Thank you Navin🎉🎉❤
@vineethyepuri58772 жыл бұрын
Answer 3:39 let a={ name:"vineeth", 'work space':4, laptop:{ ram:4, } } for(let i in a.laptop) console.log(i,a.laptop[i]) output: ram 4
@vamshi_vemula3 жыл бұрын
It's like for each loop in java . Btw Thanks for JS
@venkatathanmayiyanaparti733 жыл бұрын
Sir I am class 11 student what is the best computer language to learn? But I started learning python from ur channel is that good
@Leo-qo5hk3 жыл бұрын
Start with C programming then C++ then data structures with C and then you will find easy to learn any programming languages
@maheerathore78473 жыл бұрын
@Cool Edits good things bro
@vasantkumarks9351 Жыл бұрын
let dinga = { name : 'vasant', add : 'tmk', laptop :{ cpu : 'i5', brand1 : 'dell', } } For fetching the inner object details Answer 👇👇 for(let key in dinga.laptop) { console.log(key, dinga.laptop[key]); }
@rohanbankar43952 жыл бұрын
let stud = { studName:'Rohan', class: 'A', subject:{ sub1:'AJP', sub2:'DBMS', sub3:'OOP', } } for(let key in stud.subject){ console.log(key,stud.subject[key]); }
@beastmode3732 жыл бұрын
let user={ name: "john", id:"ugr/111/12", school:{ dep1:"cse", dep2:"com", dep3:"power", } } for(let key in user.school){ console.log(key,user.school[key]) }
@sahra.004 Жыл бұрын
let alien = { name :'sepid', tech :'JS', laptop : { cpu:'i7', ram: 4, brand: 'asus', } } for (let key in alien.laptop) { console.log(key, alien.laptop[key]) } this code leads to displaying the key values of the object which is inside alien object.
@hvardhan55 Жыл бұрын
3:40 //code for printing laptop keys along with their value for(let key in alien.laptop){ console.log(key,alien.laptop[key]) }
@maneshrao74163 жыл бұрын
Thank you Naveen Sir!!!
@kavinsg80356 ай бұрын
for (let key in alien.laptop) { console.log(key,alien.laptop[key]) } output: { name: 'kavin', technology: 'JS', 'years exp': 4, laptop: { brand: 'hp', cpu: 'i5-intel' } } brand hp cpu i5-intel
@44syagneshwar3 жыл бұрын
It is so helpful 🍀 thank you brother
@abhishekpuram5827 Жыл бұрын
answer for 3:28 let alien = { name: 'abhi', tech: 'js', laptop:{ cpu:'i7', ram:4, brand:'asus' } } for(let key in alien.laptop) { console.log(key,alien.laptop[key]); }
@ShriGuruDevoBhava2 жыл бұрын
for (let key in alien) { if (typeof alien[key]==='object'){ for (let t in alien[key]) { console.log(alien[key][t]); } } }
@muzammil9482 Жыл бұрын
answer asked for the question at 3.28 for( let key in alien.laptop){ console.log(key, alien.laptop[key]); //print key and corresponding value }
@ngawangtashi326 Жыл бұрын
to show all key value pair then use this:- let alien = { name : 'Ngawang', tech : 'phones', phones : { android_version : '12', ram : '8', brand1 : 'OnePlus' } } for(let key in alien){ console.log(key, alien[key]); } for(let key in alien.phones){ console.log(key, alien.phones[key]); }
@hariprasad-gc8bz3 жыл бұрын
Navin wanted to know how we will reduce the code in keep it in the same loop, I have tried but getting the first object value and all sending aboject values, repeating same until the loop exit.
@batambuzestephen82439 ай бұрын
@3:30 I used "p" instead of key. The for in loop statement is; for(let p in Alien.laptop){ console.log(p, Alien.laptop[p]); }
@nirusanhariharan83823 жыл бұрын
I enjoyed the content of for in loop sir thx
@karthikchowdaryynunna5382 Жыл бұрын
let cricket={ player_name:"virat", jerseyno:18, ground:{ staff:10, area:'tenyards', } } for(let key in cricket.ground) { console.log(key,cricket.ground[key]); }
@arashautomationlab90882 жыл бұрын
for(print in alien.laptop){ console.log(print, alien.laptop[print]) }
@meerfulzele55692 жыл бұрын
ANSWER FOR 3:28 let alien = { name : 'Meer', tech : 'JS', laptop : { cpu : 'i5', ram : '8GB', brand : 'HP' } } for(let key in alien.laptop) { console.log(key,alien.laptop[key]); } LIKE IF THESE IS CORRECT😁
@SriRajendraTuraga Жыл бұрын
03:31 for(let key in alien['laptop']){ console.log(key,alien.laptop[key]); }
@ritiksinha7078 Жыл бұрын
let alien ={ name : 'jaadu', height : 3, colour : 'blue', friends : { male : 5, female : 1, alien : 0 } } for(let key in alien.friends) { console.log(key,alien.friends[key]); }
@navyasri39872 жыл бұрын
3:28 for(let key in alien.laptop) { console.log(key,alien.laptop[key]) }
@AmeerMuawia-i4p2 ай бұрын
let Student= { Name : 'Ameer', Tec : 'JS', City : 'Grw', laptop : { cpu : 'i7', ram : 4, brand : 'dell' } } for(let key in Student.laptop){ console.log(key, Student.laptop[key]) }
@divyanshajain51403 жыл бұрын
let alien = { name: "Divyansha", tech : "JS", laptop: { cpu : 'i7', ram : '4', brand : 'Asus' } } for(let key in alien.laptop){ console.log(key,alien.laptop[key]); }
@gambo20033 жыл бұрын
Very good content thanks mr
@tgnsparvathi47742 жыл бұрын
assignment let user = { name : "parvathi", id: 2341, laptop : { version : "i3", brand : "hp", } } for(let key in user.laptop){ console.log(key, user.laptop[key]); } version i3 brand hp
@adityashaw6777 Жыл бұрын
ANSWER OF HW Q let i='name' let a={name: 'adi',tech:'js', laptop:{ brand:'HP', ram:'8 gb', cpu:'i7' }}; for(let key in a.laptop) { console.log(key+":"+a.laptop[key]) }
@darkhell7357 Жыл бұрын
let alien = { name: 'Suman', skillset: 'webdeveloper', work_exp : 5, laptop :{ cpu : 'core2duo', RAM : '4 gb', Brand : 'Lenevo' } } //for(let key in alien) for (let key in alien.laptop) { console.log(key, alien.laptop[key]); }
@justinram433 Жыл бұрын
let count = 1; let alien = { name : 'Justin', tech : 'js', laptop : { brand : 'mac', cpu : 'm1', ram : 8 } } for(let key in alien){ if(count==3){ break; } console.log(key, alien[key]); count++; } for(let key in alien.laptop){ console.log(key, alien.laptop[key]); }
@pooja63803 жыл бұрын
Thank you sir your videos are really helpfull 🙏❤
@AnkitSingh-bm4zc Жыл бұрын
Pur😂😂
@saiprakash22063 жыл бұрын
for(let key in alien.laptop){ console.log(key, alien.laptop[key]) }
@iamdanyaal3 жыл бұрын
Thank You Sir
@midhunramesh68283 жыл бұрын
let input='brand' let alien={ name:'Navin', tech:'js', laptop:{ brand:'hp', Cpu:'i7', ram:'8' } } for(let key in alien){ console.log(key,alien[key]) } for (let key in alien.laptop){ console.log(key,alien.laptop[key]) }
@javeedshaik33712 жыл бұрын
let alien ={ name:'Javeed', tech:'JS', laptop:{ cpu:'i7', ram:4, brand:'Lenovo' } } for(let key in alien['laptop']){ console.log(key,alien['laptop'][key]); }
@soumyajitbanerjee14403 жыл бұрын
for(let s in alien.laptop) { console.log(s,alien.laptop[s]) }
@jno1lilno2 жыл бұрын
let brotha = { name:"jerm", technology:"javascript", laptop : { cpu : "I7", ram : "4", brand : "Asus", } } for( let key in brotha.laptop) { console.log( key, brotha.laptop[key] ) I used brotha instead of alien but I messed up a little
@ritikkhandelwal15493 жыл бұрын
navin sir can you please make tutorial of API using Swagger
@manikanta-p9q Жыл бұрын
assignment for(let key in alien.laptop) { console.log(key , alien.laptop[key]); }
@hemanthdaduva28702 жыл бұрын
printing all the properties of the laptop for(let key in alien.laptop) { console.log(key,alien.laptop[key]); }
@steffqing2 жыл бұрын
I am getting an error Cannot read properties of undefined (reading 'Luke' [it's the first object])
@25prathammadhani593 жыл бұрын
3:26 for(let key in alien.laptop) { console.log(key, alien.laptop[key]); } //Output:- cpu 17 ram 4 brand Asus
For( let key in alien. laptop) { Console.log(key, alien.laptop[key]); }
@subodhthore64543 жыл бұрын
for (let key in alien.laptop) { console.log(key," ",alien.laptop[key]) }
@hackymilacky11 ай бұрын
the challenge solution: to access the list from laptop let alien = { name:'jerome', tech:'js', laptop: { brand:'mac', cpu:'fast', ram:'a lot' } } for (let key in alien.laptop) { console.log(key, alien.laptop[key]) }
@jayaprakashnarayanaraavi94243 жыл бұрын
Let student ={ name:"jaya prakash", roll:245, gadgets:{ mobile:"redmi", lap:"hp", earphones:"boat" }, }; for(i in student) { if (type of student[i]=="object ") { for(x in student[i]) { console.log(x, student[i][x]); } } else console.log(i,student[i]); }
@bhanuprakashreddy84772 жыл бұрын
3:27 Answer is Here let alien={ name:"bhanu", tech:"JS", laptop:{ cpu:'i9', ram:4, brand:'hp' } } for (let hi in alien.laptop) { //console.log(hi) //for Key Value console.log(hi,alien.laptop[hi]) }
@gobinathpalanisamy54502 ай бұрын
Without hardcode: let alien = { name: "Gobi", Job: "IT", Laptop: { brand: "mac", size: 16 } }; // Iterate over the keys of the alien object for (let key in alien) { console.log(key, alien[key]); // Check if the value of the current key is an object if (typeof alien[key] === 'object' && alien[key] !== null) { // Iterate over the keys of the nested object for (let nestedKey in alien[key]) { console.log(nestedKey, alien[key][nestedKey]); } } }
@NaveenKumar-hy5et2 жыл бұрын
for( var key in alien.loptop) { console.log(key, alien.loptop[key]); }
@barbarasanchezvasquez22422 жыл бұрын
Thanks.
@kalyanimathur5423 Жыл бұрын
Timestamp 3:30 let alien = { name: 'Navin', tech: 'JS', laptop: { cpu: 'i7', ram: 4, brand:'Asus', make: 'India' } } for (let key in alien.laptop){ console.log(key,alien.laptop[key]); } //Output cpu i7 ram 4 brand Asus make India
@bhumit0703 жыл бұрын
I think this is the right answer function printObj(obj) { for (let key in obj) { if (typeof obj[key] === 'object') { printObj(obj[key]); } else { console.log(key, obj[key]); } } } const person = { name: 'Javascript', age: 25, laptop: { brand: 'Lenovo', screen_size: '14inch', processor: 'AMD Ryzen 5', }, passion: 'Web Dev', }; printObj(person)
@ruthvikparate34213 жыл бұрын
for (let key in user.laptop) { console.log(key, user.laptop[key]); }
@shubhamagarwal62312 жыл бұрын
3:45 --> let alien={ name : 'xyz', tech : 'JS', laptop : { cpu:'i7', ram:16, brand:'Asus' } } for(key in alien.laptop){ // console.log(key,alien[key]); console.log(key,alien.laptop[key]); }
@rohithkumar44983 жыл бұрын
for (let key in alien.laptop) { console.log(key,alien.laptop[key]); }
@coolgirlsharu3 жыл бұрын
In JavaScript foreach and for in both are same?
@jayantamondal3242 Жыл бұрын
let input = 'agee'; let tech = { name : 'JS', age : { from : 1995, to: 2023 }, laptop : { brand : 'Dell', processor : 'AMD', conif : { ram : '8gb', storage : { type : 'SSD', amount : 512 } } } } function innerObjects(objects) { for(let key in objects) { console.log(key); if(typeof objects[key] === 'object') { innerObjects(objects[key]); } } } innerObjects(tech);
@komaduraisamidurai75512 жыл бұрын
for (let key in alien.laptop) console.log(key,alien.laptop[key]) its working but getting only laptop key values i dont know how to print all the values
@tsheringyangden8576 Жыл бұрын
let object={ name:"Tshering", enRoll:66, gadgets:{ laptop: "Dell", Phone:'Oppo' } } for(let p in object.gadgets){ console.log(p, object.gadgets[p]); }
@falcon04v82 жыл бұрын
// fetching data by using "for in loop" let identity = { name : 'Niel', job : 'developer', 'work exp' : '3years', 'device uses' : { laptop_brand : 'Asus', RAM : '32 Gb', CPU : 'intel i9' } } console.log("printing key of identity"); for(let i in identity){ console.log(i); } console.log(" printing key and value of identity"); for(let i in identity){ console.log(i, identity[i]); } console.log(" printing key and value of device uses"); for(let i in identity['device uses']){ console.log(i, identity['device uses'][i]); }
@inmermoiseszorrillagonzale32902 жыл бұрын
3:26 Answer let alien = { name: "Navin", tech: "JS", laptop: { cpu: "i7", ram: 4, brand: "asus", }, }; for (let key in alien) { console.log(key, alien[key]); } const laptopObject = alien.laptop; for (let keyName in laptopObject) { console.log(keyName, laptopObject[keyName]); }