Created
July 20, 2015 11:16
-
-
Save Bambina-zz/7637b4337c2482ae46c1 to your computer and use it in GitHub Desktop.
js use call method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pi = { //変数piにオブジェクトを代入する。jsのオブジェクトはプロパティの集合である。 | |
name: "pipipi" | |
} | |
var hi = function(name){ //オブジェクトを受け取って、そのオブジェクトのnameプロパティを表示する無名関数を変数を | |
console.log( "name is"+ this.name ); | |
} | |
hi.call(pi); //本来piオブジェクトが持っていないhiメソッドを適用する。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment