So recently, i often to come across instagram post that invokes javascript i.e. like this --> foo.bar().baz().qux();. The insertion of parameters can be done on so many levels. However from what i have just learned, in nested object literal, we can only do foo.bar.baz.qux(); or only one parameter insertion. Can anyone show how to create nested object literals that can be invoked like this --> foo.bar().baz().qux(); ? ^cheers,
Asked
Active
Viewed 40 times
0
-
1Instagram posts invoke JavaScript now? This is essentially just a function that returns an Object, that has a function in it, that again returns an Object with a function in it. – Luca Kiebel Sep 11 '18 at 12:04
-
Each of those methods returns object, probably `this`. It's so called chaining http://jscriptpatterns.blogspot.com/2012/09/chaining-pattern.html – ponury-kostek Sep 11 '18 at 12:05
-
it was a photo. of course, XD can you show how to create one? im kind of lost here. ive just learned programming. but sometimes random confusion comes across. – marcius.tan Sep 11 '18 at 12:05
-
Nina Scholz Taking properties. How to build one? *cheers, – marcius.tan Sep 11 '18 at 12:10
-
Oh GOD! i got duplicate mark right away!... which mean s its answered.. stackoverflow is the ultimate.. thx!! im happy now.. – marcius.tan Sep 11 '18 at 12:11