I have the following example code
var object = {
userDefinedFunction : function(){
//no implementation, this will be defined by the user
}
}
What i want to achieve is the user giving his own implementation of it:
object.userDefinedFunction = function(){
alert("just testing");
}
I tested this and works as i expected, what i want to know is:
- is this the javascript way of solving this kind of problem?
-
let’s say that it’s mandatory that
userDefinedFunctionis implemented, how do i make sure of this? I could rely on something like the following, checking forimplemented, but i’m learning javascript so i want to know how to leverage the language:userDefinedFunction : function(){ implemented = false; }
Thank you.
hasUserImplementedInterfaces()function checks for user function implementations so you can execute as first check using that object.