Created
December 25, 2012 05:04
-
-
Save yllan/4371703 to your computer and use it in GitHub Desktop.
javascript 小嫩嫩自婊記
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 STATE_CASE_1 = 0, | |
| STATE_CASE_2 = 1, | |
| STATE_CASE_3 = 2, | |
| DEFAULT_CASE = 99999; | |
| var dict = { | |
| STATE_CASE_1: function (s) { /**/ }, // The key is not its Number value! It's String "STATE_CASE_1"! | |
| STATE_CASE_2: function (s) { /**/ }, | |
| STATE_CASE_3: function (s) { /**/ }, | |
| DEFAULT_CASE: function (s) { /**/ } | |
| }; | |
| dict[STATE_CASE_1] === undefined; | |
| // Try dict.STATE_CASE_1 or dict["STATE_CASE_1"]. |
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 Fruit = function(name) { | |
| this.fruit = name; | |
| this.eat = function() { console.log("Eat " + this.fruit); }; | |
| }; | |
| var banana = new Fruit("BANANA"); | |
| banana.eat(); // Eat BANANA | |
| var eatFunction = banana.eat; | |
| eatFunction(); // Eat undefined | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
eat my banana~