1. 概述
可以创建一个函数, 在内部封装new。
function Student(props){ this.name = props.name || ‘匿名‘; this.grade = props.grade || 1; } Student.prototype.hello = function(){ alert(‘Hello, ‘+ this.name + ‘!‘); } function createStudent(props){ return new Student(props || {}); }
原文:http://www.cnblogs.com/rocky-fang/p/5762184.html