Javascript default object method -


is there way how create default method call when method called object undefined?

e.g.

myobj = {    default: function(){        console.log("you've called method isn't defined");    },    sayhi: function(){        console.log("myobj says hi!");    } }  //console output: "myobj says hi!" myobj.sayhi();  //console output: "you've called method isn't defined" myobj.methodthatisnotreallythere();  


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -