Created
August 16, 2011 14:51
-
-
Save xulapp/1149281 to your computer and use it in GitHub Desktop.
残酷な getter
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"> | |
| <title></title> | |
| <script> | |
| var akarin = {name: 'あかり'}; | |
| var yryr = Object.create(null, { | |
| standby: {value: standby}, | |
| start: {get: getStart}, | |
| }); | |
| function standby(c) { | |
| c.serifu = 'はっじまーるよー!'; | |
| return c; | |
| } | |
| function start(c) { | |
| alert(c.name + '「' + c.serifu + '」'); | |
| } | |
| function getStart() { | |
| akarin.serifu = ''; | |
| return start; | |
| } | |
| function test1() { | |
| yryr.start(yryr.standby(akarin)); | |
| } | |
| function test2() { | |
| yryr.standby(akarin) | |
| yryr.start(akarin); | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <button onclick="test1()">あかりん 1</button> | |
| <button onclick="test2()">あかりん 2</button> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment