/**
* Created by zengxianwen on 2016/6/13.
*/
/**
* 对象之字面量表示方式
* @type {{checkName: checkObject.checkName, checkEmail: checkObject.checkEmail, checkPwd: checkObject.checkPwd}}
*/
var checkObject = {
checkName : function () {
console . log ( 'checkName' );
},
checkEmail : function () {
console . log ( 'checkEmail' );
},
checkPwd : function () {
console . log ( 'checkPwd' );
}
}
checkObject . checkName ();
/**
* 对象之另一种表示方式
*/
var checkObject_1 = function () {}
checkObject_1 . checkName = function () {
console . log ( 'checkObject_1.checkName' )
}
checkObject_1 . checkEmail = function () {
console . log ( 'checkObject_1.checkEmail' )
}
checkObject_1 . checkPwd = function (){
console . log ( 'checkObject_1.checkPwd' )
}
checkObject_1 . checkName ();
/**
* 类之本身表示方式
* @constructor
*/
var CheckObject = function () {
this . checkEmail = function () {
console . log ( 'CheckObject.checkEmail' );
return
};
this . checkName = function () {
console . log ( 'CheckObject.checkName' );
};
this . checkPwd = function () {
console . log ( 'CheckObject.checkPwd' );
};
}
var c = new CheckObject ();
c . checkName ();
/**
* 减小开销,类之原型表示方式
* @constructor
*/
var CheckObject_1 = function () {};
CheckObject_1 . prototype = {
checkName : function () {
console . log ( 'CheckObject_1.checkName' );
},
checkEmail : function () {
console . log ( 'CheckObject_1.checkEmail' );
},
checkPwd : function () {
console . log ( 'CheckObject_1.checkPwd' );
}
}
new CheckObject_1 (). checkEmail ();
console . log ( '以下写法为,访问方式为链式访问方式' );
/**
* 类之本身表示方式,访问方式为链式
* @constructor
*/
var CheckObject_2 = function () {
this . checkEmail = function () {
console . log ( 'CheckObject_2.checkEmail' );
return this ;
};
this . checkName = function () {
console . log ( 'CheckObject_2.checkName' );
return this ;
};
this . checkPwd = function () {
console . log ( 'CheckObject_2.checkPwd' );
return this ;
};
}
var c1 = new CheckObject_2 ();
c1 . checkName (). checkEmail ();
/**
* 减小开销,类之原型表示方式,访问方式为链式访问方式
* @constructor
*/
var CheckObject_3 = function () {};
CheckObject_3 . prototype = {
checkName : function () {
console . log ( 'CheckObject_3.checkName' );
return this ;
},
checkEmail : function () {
console . log ( 'CheckObject_3.checkEmail' );
return this ;
},
checkPwd : function () {
console . log ( 'CheckObject_3.checkPwd' );
return this ;
}
}
new CheckObject_3 (). checkEmail (). checkName ();
* Created by zengxianwen on 2016/6/13.
*/
/**
* 对象之字面量表示方式
* @type {{checkName: checkObject.checkName, checkEmail: checkObject.checkEmail, checkPwd: checkObject.checkPwd}}
*/
var checkObject = {
checkName : function () {
console . log ( 'checkName' );
},
checkEmail : function () {
console . log ( 'checkEmail' );
},
checkPwd : function () {
console . log ( 'checkPwd' );
}
}
checkObject . checkName ();
/**
* 对象之另一种表示方式
*/
var checkObject_1 = function () {}
checkObject_1 . checkName = function () {
console . log ( 'checkObject_1.checkName' )
}
checkObject_1 . checkEmail = function () {
console . log ( 'checkObject_1.checkEmail' )
}
checkObject_1 . checkPwd = function (){
console . log ( 'checkObject_1.checkPwd' )
}
checkObject_1 . checkName ();
/**
* 类之本身表示方式
* @constructor
*/
var CheckObject = function () {
this . checkEmail = function () {
console . log ( 'CheckObject.checkEmail' );
return
};
this . checkName = function () {
console . log ( 'CheckObject.checkName' );
};
this . checkPwd = function () {
console . log ( 'CheckObject.checkPwd' );
};
}
var c = new CheckObject ();
c . checkName ();
/**
* 减小开销,类之原型表示方式
* @constructor
*/
var CheckObject_1 = function () {};
CheckObject_1 . prototype = {
checkName : function () {
console . log ( 'CheckObject_1.checkName' );
},
checkEmail : function () {
console . log ( 'CheckObject_1.checkEmail' );
},
checkPwd : function () {
console . log ( 'CheckObject_1.checkPwd' );
}
}
new CheckObject_1 (). checkEmail ();
console . log ( '以下写法为,访问方式为链式访问方式' );
/**
* 类之本身表示方式,访问方式为链式
* @constructor
*/
var CheckObject_2 = function () {
this . checkEmail = function () {
console . log ( 'CheckObject_2.checkEmail' );
return this ;
};
this . checkName = function () {
console . log ( 'CheckObject_2.checkName' );
return this ;
};
this . checkPwd = function () {
console . log ( 'CheckObject_2.checkPwd' );
return this ;
};
}
var c1 = new CheckObject_2 ();
c1 . checkName (). checkEmail ();
/**
* 减小开销,类之原型表示方式,访问方式为链式访问方式
* @constructor
*/
var CheckObject_3 = function () {};
CheckObject_3 . prototype = {
checkName : function () {
console . log ( 'CheckObject_3.checkName' );
return this ;
},
checkEmail : function () {
console . log ( 'CheckObject_3.checkEmail' );
return this ;
},
checkPwd : function () {
console . log ( 'CheckObject_3.checkPwd' );
return this ;
}
}
new CheckObject_3 (). checkEmail (). checkName ();