diff options
Diffstat (limited to 'bootstrap/comments/frontend/optionalmethod.js')
-rw-r--r-- | bootstrap/comments/frontend/optionalmethod.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bootstrap/comments/frontend/optionalmethod.js b/bootstrap/comments/frontend/optionalmethod.js new file mode 100644 index 0000000..86415a8 --- /dev/null +++ b/bootstrap/comments/frontend/optionalmethod.js @@ -0,0 +1,11 @@ +// Calls a method that may or may not exist (optionalmethod.js) +HashOverConstructor.prototype.optionalMethod = function (name, args, object) +{ + var method = object ? this[object][name] : this[name]; + var context = object ? this[object] : this; + + // Check if the method exists + if (method && typeof (method) === 'function') { + return method.apply (context, args); + } +}; |