Skip to content

Instantly share code, notes, and snippets.

@17
Last active August 29, 2015 14:02
Show Gist options
  • Save 17/288312be28eefdb3e716 to your computer and use it in GitHub Desktop.
Save 17/288312be28eefdb3e716 to your computer and use it in GitHub Desktop.
var cat = function (hands, feet) {
this.hands = hands
this.feet = feet
},
fatcat = function (hands, feet, kg) {
this.kg = kg
console.log(this)
cat.call(this, hands, feet)
// 我在这里以**当前作用域**运行了 cat
// **相当于** 在这里运行了
// +function (that, hands, feet) {
// that.hands = hands
// that.feet = feet
// }(this, hands, feet)
// 然后我就多了 this.hands 和 this.feet
//
return this
},
mycat = new fatcat(0, 0, 50);
console.log(mycat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment