Javascript
I've made an object with properties in which made further functions and nested object. Now,the problem is that nested object and the functions, not displaying on the screen while using for-in loop.
var obj = {
fname: 'abc',
lname: 'xyz',
date: 4,
year: 2022,
// Nested object with further a property hobbies.
nestedObj: {
hobbies: 'nothing'
},
// As you can see, these are the two functions that i want to display using for-in loop
fun: function () {
return 0;
},
fullname: function () {
return this.fname + ' ' + this.lname;
}
};
// i think i am missing something for example any-condition, while declaring the for-in loop.
for (var key in obj) {
// The break tag is used to display all the object properties to the next line to each other
document.write(obj[key] + '<br>');
}
What do you think? Can you do it? any suggestions would be considerable. Consider yourself heartily thanked!!