**
* 浅复制
* @returns {F}
*/
function prototypeExtend() {
var F = function () {},args = arguments,
i = 0,
len = args.length;
for(; i < len ; i ++){
for(var j in args[i]){
F.prototype[j] = args[i][j];
}
}
return new F();
}
var penguin = prototypeExtend({
speed:20,
swin:function () {
console.log('speed --' + this.speed);
}},{run:function (speed) {
console.log('run speed--' + speed);
}},{jump:function () {
console.log('jump action');
}});
* 浅复制
* @returns {F}
*/
function prototypeExtend() {
var F = function () {},args = arguments,
i = 0,
len = args.length;
for(; i < len ; i ++){
for(var j in args[i]){
F.prototype[j] = args[i][j];
}
}
return new F();
}
var penguin = prototypeExtend({
speed:20,
swin:function () {
console.log('speed --' + this.speed);
}},{run:function (speed) {
console.log('run speed--' + speed);
}},{jump:function () {
console.log('jump action');
}});