javascript設計模式

1、面向對象編程

           一、從一個示例的演進來理解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() {}
  };
};

           

2、建立型設計模式

相關文章
相關標籤/搜索