用ES5实现ES6中的class;
function _defineProperties(target,prop){
prop.forEach(ele => {
Object.defineProperty(target,ele.key,{
value:ele.value,
writable:true,
configurable:true,
})
});
}
function _createClass(_constructor,_prototypeProperties,_staticProperties){
if(_prototypeProperties){
_defineProperties(_constructor.prototype,_prototypeProperties)
}
if(_staticProperties){
_defineProperties(_constructor,_staticProperties)
}
}
function _classCallCheck(_this,_constructor){
if(!(_this instanceof _constructor)){
throw "TypeError: Class constructor AirPlane cannot be invoked without 'new'"
}
}
var FatherPlane=(function(){
function FatherPlane(name,color){
_classCallCheck(this,FatherPlane)
this.name=name||'liu';
this.color=color||'red'
}
_createClass(FatherPlane,[
{
key:'fly',
value:function(){
console.log('fly')
}
}
],[
{
key:'static',
value:function(){
console.log('static')
}
}
])
return FatherPlane;
})()
var airplane=new FatherPlane()