/ Published in: JavaScript

Namespace to avoid collision with other javascript variable/method names
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var NAMESPACE ={}; NAMESPACE.MyClassName = function () { this.initialize.apply(this, arguments); }; NAMESPACE.MyClassName.prototype = { value1: null, value2: null, initialize: function(arg1, arg2) { this.value1 = arg1; this.value2 = arg2; }, addItUp: function () { var total = this.value1 + this.value2; return total; } }; // new instance var newInstance = new NAMESPACE.MyClassName('it ',' works!') newInstance.addItUp();
Comments
