Created
October 31, 2011 08:57
-
-
Save sawamur/1327144 to your computer and use it in GitHub Desktop.
JS中級コース向けレベルチェック
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
//下記ソースを読んで設問に答えよ | |
function User(name){ | |
this.name = name; | |
} | |
User.prototype.introduce = function(){ | |
return "Hi! My name is " + this.name; | |
}; | |
function user(name){ | |
var _name = name; | |
function introduce(){ | |
return "Hi! My name is " + _name; | |
} | |
return { | |
introduce: introduce | |
}; | |
} | |
// Q1. 下記二つの違いを説明せよ | |
var john = new User("John"); | |
var paul = user("Paul"); | |
// Q2. 下記はコンソールに4行出力する。どうなるか予想せよ | |
console.log( john.introduce() ); | |
console.log( john.name ); | |
console.log( paul.introduce() ); | |
console.log( paul.name ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment