Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function killSomeone(person) {
- person.alive = false;
- console.log(person.fullName + " is killed.");
- // The magical line to catch the bad guy red handed!
- console.log(this);
- }
- var good_guy = {
- fullName: "The Good Guy",
- alive: true
- };
- var bad_guy = {
- fullName: "The Bad Guy",
- alive: true
- };
- // bad guy learns about killSomeone and borrows it.
- bad_guy.killForFun = killSomeone;
- bad_guy.killForFun(good_guy);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement