SOURCE

//安全模式创建的工厂类
var Factory = function(type, content) {
  if(this instanceof Factory) {
    return new this[type](content);
  } else {
    return new Factory(type, content);
  }
}
//工厂原型中设置创建所有类型数据对象的基类
Factory.prototype = {
  Java: function(content) {
    this.content = content;
    (function(content){
      var div = document.createElement("div");
      div.innerHTML = content;
      div.style.color = "green";
      document.getElementById("container").appendchild(div);
    })(content);
  },
  php: function(content) {
    ...
  }
}
console 命令行工具 X clear

                    
>
console