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 || {});}
原标题:js 创建对象模式
关键词:JS