Javascript examples for Object:Object Method
call or autoload another method if calling method is undefined
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*w w w .j av a 2 s . c om*/ function MyObject() { this.methodDefined = function() { console.log('Mom was called.'); } this.exceptionHandler = function() { console.log('Catch all was called'); } } q = new MyObject(); q.methodDefined(); q.methodNotDefined ? q.methodNotDefined() : q.exceptionHandler(); } </script> </head> <body> </body> </html>