Javascript examples for Function:Function Variable
Assign JavaScript function as variable and call it
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// ww w.ja va 2s.co m var o = {}; o.name = 'foo'; var f = function() { return this.name; } o.someFunction = f; var result = o.someFunction(); document.getElementById("test").innerHTML = result; } </script> </head> <body> <div id="test"> This text will change </div> </body> </html>