Is there a way how to create a default method call when the method that is called from object is undefined?
e.g.
myObj = {
default: function(){
console.log("You've called method that isn't defined");
},
sayHi: function(){
console.log("myObj says Hi!");
}
}
//console output: "myObj says Hi!"
myObj.sayHi();
//console output: "You've called method that isn't defined"
myObj.methodThatIsNotReallyThere();
.call('name')and use the string to look up a method in in an object used as a dictionary. If the named method is undefined, then .call could execute something else.