Skip to content
Advertisement

Call functions from function inside an object (object literal)

I’m learning to use object literals in JS, and I’m trying to get a function inside an object to run by calling it through another function in the same object. Why isn’t the function “run” running when calling it from the function “init”?

JavaScript

Advertisement

Answer

That code is only a declaration. You need to actually call the function:

JavaScript

Demo: http://jsfiddle.net/mattball/s6MJ5/

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement