一、從一個示例的演進來理解javascript
驗證表單功能--不污染全局做用域java
function checkName() {} function checkEmail() {} function checkPassword() {} //申明變量 var checkName = function() {}; var checkEmail = function() {}; var checkPassword = function() {}; //用對象收編 var checkObj = { checkName: function() {}, checkEmail: function() {}, checkPawword: function() {} }; var checkObj = {}; checkObj.checkName = function() {}; checkObj.checkEmail = function() {}; checkObj.checkPawword = function() {}; var checkObj = function() { return { checkName: function() {}, checkEmail: function() {}, checkPawword: function() {} }; };