Javascript examples for Object:Object Literal
Pass function in an object literal with parameters
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script type="text/javascript"> //Define the function var need = {//from w w w .j av a2 s. co m myFunc:function(token){ console.log(token) } }; // Invoking need['myFunc'](1); //dynamic invoke var dynamicInvoke = 'myFunc'; need[dynamicInvoke](2); </script> </body> </html>