DEV Community

loading...

Discussion on: A little tip on running functions on JS objects

Collapse
belzeme profile image
cbelvisee

Well, I did try your code there. With the proper js syntax, there is no problem.

let obj = {
 foo: [1, 2, 3, 4], 
 bar: [1, {yah: 'yeet', yheezy: [1, 3, 4]}]
};

console.log(obj.foo.length); //4
console.log(obj.bar[1].yheezy.length); //3
Collapse
jamesscaur profile image
James Scaur Author

Ah! Thanks for pointing that out... what if yheezy was an variable? Could you still use dot-notation?