<body>
<script type="text/javascript">
/**
* 形式一:
*/
// function checkName() {
// console.log('checkName running_1') ;
// } ;
// function checkEmail() {
// console.log('checkEmail running_1') ;
// } ;
// function checkPassword() {
// console.log('checkPassword running_1') ;
// } ;
// checkName() ;
// checkEmail() ;
// checkPassword() ;
/**
* 形式二:
*/
// var checkName = function() {
// console.log('checkName running_2') ;
// } ;
// var checkEmail = function() {
// console.log('checkEmail running_2') ;
// } ;
// var checkPassword = function() {
// console.log('checkPassword running_2') ;
// } ;
// checkName() ;
// checkEmail() ;
// checkPassword() ;
/**
* 形式三:
*/
// var CheckObject = {
// checkName : function() {
// console.log('checkName running_3') ;
// },
// checkEmail : function() {
// console.log('checkEmail running_3') ;
// },
// checkPassword : function() {
// console.log('checkPassword running_3') ;
// }
// } ;
// CheckObject.checkName() ;
// CheckObject.checkEmail() ;
// CheckObject.checkPassword() ;
/**
* 形式四:
*/
// var CheckObject = function() {};
// CheckObject.checkName = function() {
// console.log('checkName running_4') ;
// } ;
// CheckObject.checkEmail = function() {
// console.log('checkEmail running_4') ;
// } ;
// CheckObject.checkPassword = function() {
// console.log('checkPassword running_4') ;
// } ;
// CheckObject.checkName() ;
// CheckObject.checkEmail() ;
// CheckObject.checkPassword() ;
/**
* 形式五:
*/
// var CheckObject = function() {
// return {
// checkName : function() {
// console.log('checkName running_5') ;
// },
// checkEmail : function() {
// console.log('checkEmail running_5') ;
// },
// checkPassword : function() {
// console.log('checkPassword running_5') ;
// }
// }
// }
// var co = CheckObject() ;
// co.checkName() ;
// co.checkEmail() ;
// co.checkPassword() ;
/**
* 形式六:
*/
// var CheckObject = function() {
// this.checkName = function() {
// console.log('checkName running_6') ;
// } ;
// this.checkEmail = function() {
// console.log('checkEmail running_6') ;
// } ;
// this.checkPassword = function() {
// console.log('checkPassword running_6') ;
// }
// } ;
// var co = new CheckObject() ;
// co.checkName() ;
// co.checkEmail() ;
// co.checkPassword() ;
/**
* 形式七-1:
*/
// var CheckObject = function() {} ;
// CheckObject.prototype.checkName = function() {
// console.log('checkName running_7') ;
// } ;
// CheckObject.prototype.checkEmail = function() {
// console.log('checkEmail running_7') ;
// } ;
// CheckObject.prototype.checkPassword = function() {
// console.log('checkPassword running_7') ;
// }
// var co = new CheckObject() ;
// co.checkName() ;
// co.checkEmail() ;
// co.checkPassword() ;
/**
* 形式七-2:
*/
// var CheckObject = function() {} ;
// CheckObject.prototype = {
// checkName : function() {
// console.log('checkName running_7-2') ;
// },
// checkEmail : function() {
// console.log('checkEmail running_7-2') ;
// },
// checkPassword : function() {
// console.log('checkPassword running_7-2') ;
// }
// } ;
// var co = new CheckObject() ;
// co.checkName() ;
// co.checkEmail() ;
// co.checkPassword() ;
/**
* 形式八-1:
*/
// var CheckObject = {
// checkName : function() {
// console.log('checkName running_8-1') ;
// return this ;
// },
// checkEmail : function() {
// console.log('checkEmail running_8-1') ;
// return this ;
// },
// checkPassword : function() {
// console.log('checkPassword running_8-1') ;
// return this ;
// }
// } ;
// CheckObject.checkName().checkEmail().checkPassword() ;
/**
* 形式八-2:
*/
// var CheckObject = function() {} ;
// CheckObject.prototype = {
// checkName : function() {
// console.log('checkName running_8-2') ;
// return this ;
// },
// checkEmail : function() {
// console.log('checkEmail running_8-2') ;
// return this ;
// },
// checkPassword : function() {
// console.log('checkPassword running_8-2') ;
// return this ;
// }
// } ;
// var co = new CheckObject() ;
// co.checkName().checkEmail().checkPassword() ;
/**
* 形式九-1(prototype.js):
*/
// Function.prototype.checkName = function() {
// console.log('checkName running_9-1[prototype.js]') ;
// } ;
// // 函数形式
// var f1 = function() {};
// f1.checkName() ;
// // 类形式
// var f2 = new Function() ;
// f2.checkName() ;
/**
* 形式九-2(prototype.js):
*/
// Function.prototype.addMethods = function(name, fn) {
// this[name] = fn ;
// } ;
// // 函数形式
// var methods1 = function() {} ;
// // 类形式
// var methods2 = new Function() ;
// methods1.addMethods('checkName', function() {
// console.log('checkName running_9-2[prototype.js]') ;
// }) ;
// methods2.addMethods('checkEmail', function() {
// console.log('checkEmail running_9-2[prototype.js]') ;
// }) ;
// methods1.checkName() ;
// methods2.checkEmail() ;
/**
* 形式十-1(prototype.js):
*/
// Function.prototype.addMethods = function(name, fn) {
// this[name] = fn ;
// return this ;
// } ;
// var methods = new Function() ;
// methods.addMethods('checkName', function() {
// console.log('checkName running_10-1[prototype.js]') ;
// }).addMethods('checkEmail', function(){
// console.log('checkEmail running_10-1[prototype.js]') ;
// }).addMethods('checkPassword', function() {
// console.log('checkPassword running_10-1[prototype.js]') ;
// }) ;
// methods.checkName() ;
// methods.checkEmail() ;
// methods.checkPassword() ;
/**
* 形式十-2(prototype.js):
*/
// Function.prototype.addMethods = function(name, fn) {
// this[name] = fn ;
// return this ;
// } ;
// var methods = new Function() ;
// methods.addMethods('checkName', function() {
// console.log('checkName running_10-2[prototype.js]') ;
// return this ;
// }).addMethods('checkEmail', function() {
// console.log('checkEmail running_10-2[prototype.js]') ;
// return this ;
// }).addMethods('checkPassword', function() {
// console.log('checkPassword running_10-2[prototype.js]') ;
// return this ;
// }) ;
// methods.checkName().checkEmail().checkPassword() ;
/**
* 形式十一-1(prototype.js):
*/
Function.prototype.addMethods = function(name, fn){
this.prototype[name] = fn ;
return this ;
} ;
var Methods = function() {} ;
Methods.addMethods('checkName', function() {
console.log('checkName running_11-1[prototype.js]') ;
return this ;
}).addMethods('checkEmail', function() {
console.log('checkEmail running_11-1[prototype.js]') ;
return this ;
}).addMethods('checkPassword', function() {
console.log('checkPassword running_11-1[prototype.js]') ;
return this ;
}) ;
var m = new Methods() ;
m.checkName().checkEmail().checkPassword() ;
</script>
</body>