Created
December 19, 2016 15:57
-
-
Save anonymous/a515ec5e20db3f43105b42bc81510c53 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/qesodaf
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var User = (function() { | |
var _age; | |
function User(name) { | |
this.name = name; | |
_age = 10; | |
} | |
User.prototype.agree = function() { | |
return "Hello, " + this.name; | |
}; | |
User.prototype.age = function() { | |
_say.call(this); | |
return _age; | |
}; | |
_say = function() { | |
console.log(this); | |
var _self = this; | |
var kuro = function() { | |
console.log(User.prototype.agree()); | |
console.log(_self.agree()); | |
}; | |
kuro(); | |
return "say"; | |
} | |
return User; | |
})(); | |
var user = new User("Bob"); | |
user.hoge = function() { | |
_say.call(this); | |
}; | |
console.log(user.agree()); | |
console.log(user.name); | |
console.log(user.age()); | |
console.log(user.hoge()); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var User = (function() { | |
var _age; | |
function User(name) { | |
this.name = name; | |
_age = 10; | |
} | |
User.prototype.agree = function() { | |
return "Hello, " + this.name; | |
}; | |
User.prototype.age = function() { | |
_say.call(this); | |
return _age; | |
}; | |
_say = function() { | |
console.log(this); | |
var _self = this; | |
var kuro = function() { | |
console.log(User.prototype.agree()); | |
console.log(_self.agree()); | |
}; | |
kuro(); | |
return "say"; | |
} | |
return User; | |
})(); | |
var user = new User("Bob"); | |
user.hoge = function() { | |
_say.call(this); | |
}; | |
console.log(user.agree()); | |
console.log(user.name); | |
console.log(user.age()); | |
console.log(user.hoge()); | |
</script></body> | |
</html> |
This file contains hidden or 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 User = (function() { | |
var _age; | |
function User(name) { | |
this.name = name; | |
_age = 10; | |
} | |
User.prototype.agree = function() { | |
return "Hello, " + this.name; | |
}; | |
User.prototype.age = function() { | |
_say.call(this); | |
return _age; | |
}; | |
_say = function() { | |
console.log(this); | |
var _self = this; | |
var kuro = function() { | |
console.log(User.prototype.agree()); | |
console.log(_self.agree()); | |
}; | |
kuro(); | |
return "say"; | |
} | |
return User; | |
})(); | |
var user = new User("Bob"); | |
user.hoge = function() { | |
_say.call(this); | |
}; | |
console.log(user.agree()); | |
console.log(user.name); | |
console.log(user.age()); | |
console.log(user.hoge()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment