Javascript examples for Function:Function Variable
Use var to create function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*w w w . ja va 2s . com*/ var init = function(){ return { hello: function(){ console.log("hello"); }, world: function(){ console.log("world"); } }; }; var f = init(); f.hello(); f.world(); } </script> </head> <body> </body> </html>