Return to Snippet

Revision: 14935
at June 17, 2009 16:09 by inkdeep


Initial Code
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();

Initial URL

                                

Initial Description
Namespace to avoid collision with other javascript variable/method names

Initial Title
Javascript Class with instance creation arguments

Initial Tags
javascript, js

Initial Language
JavaScript