Tuesday 25 August 2015

Javascript Object oriented Main Concepts

Javascript Object oriented Main Concepts

Create Global Namespace


var Myns= Myns|| {};
 
 
MYAPP.commonMethod = {
  regExForName: "", 
  regExForPhone: "", 
  validateName: function(name){
    
    
  },
 
  validatePhoneNo: function(phoneNo){
    // do with number
  }
}

// Object together with the method declarations
MYAPP.event = {
    addListener: function(el, type, fn) {
    // code stuff
    },
    removeListener: function(el, type, fn) {
    // code stuff
    },
    getEvent: function(e) {
    // code stuff
    }
  
    // Can add another method and properties
}

// Syntax for Using addListener method:
MYAPP.event.addListener("anynm", "type", callback); 
 

0 comments:

Post a Comment

 

Subscribe to our Newsletter

Contact our Support

Email us: youremail@gmail.com

Our Team Memebers