Skip to content

Instantly share code, notes, and snippets.

@sawamur
Created October 31, 2011 08:57
Show Gist options
  • Save sawamur/1327144 to your computer and use it in GitHub Desktop.
Save sawamur/1327144 to your computer and use it in GitHub Desktop.
JS中級コース向けレベルチェック
//下記ソースを読んで設問に答えよ
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