Last active
August 29, 2015 14:05
-
-
Save dherman/d40e2e73c6770dce0ff8 to your computer and use it in GitHub Desktop.
This file contains 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
// arguments.length === 0 | |
dict = new Dict(); | |
// arguments.length > 0, typeof arguments[0][@@iterator]] !== 'undefined' | |
dict = new Dict([["a", 1], ["b", 2], ["c", 3]]); | |
// arguments.length > 0, typeof arguments[0][@@iterator] === 'undefined' | |
dict = new Dict({ "a": 1, "b": 2, "c": 3 }) | |
// arguments.length === 1, typeof arguments[0][@@iterator] === 'undefined' | |
dict.set({ | |
"a": 1, | |
"b": 2, | |
"c": 3 | |
}); | |
// arguments.length === 1, typeof arguments[0][@@iterator] !== 'undefined' | |
dict.set([ | |
["a", 1], | |
["b", 2], | |
["c", 3] | |
]); | |
// arguments.length > 1 | |
dict.set({ toString() { return "a" } }, 1); // sets a => 1 | |
// arguments.length > 1 | |
dict.set("a", 1); // sets a => 1 | |
// arguments.length === 1, typeof arguments[0] === 'string' | |
dict.set("a") // throws |
This file contains 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
// arguments.length === 0 | |
dict = new Dict(); | |
// arguments.length > 0, typeof arguments[0][@@iterator]] !== 'undefined' | |
dict = new Dict([["a", 1], ["b", 2], ["c", 3]]); | |
// arguments.length > 0, typeof arguments[0][@@iterator] === 'undefined' | |
dict = new Dict({ "a": 1, "b": 2, "c": 3 }) | |
// arguments.length === 1, typeof arguments[0][@@iterator] === 'undefined' | |
dict.set({ | |
"a": 1, | |
"b": 2, | |
"c": 3 | |
}); | |
// arguments.length === 1, typeof arguments[0][@@iterator] !== 'undefined' | |
dict.set([ | |
["a", 1], | |
["b", 2], | |
["c", 3] | |
]); | |
// arguments.length > 1, typeof arguments[0] !== 'string' | |
dict.set({ toString() { return "a" } }, 1); // throws | |
// arguments.length > 0, typeof arguments[0] === 'string' | |
dict.set("a", 1); // sets a => 1 | |
// arguments.length > 0, typeof arguments[0] === 'string' | |
dict.set("a") // a => undefined |
This file contains 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
// arguments.length === 0 | |
dict = new Dict(); | |
// arguments.length > 0, typeof arguments[0][@@iterator]] !== 'undefined' | |
dict = new Dict([["a", 1], ["b", 2], ["c", 3]]); | |
// arguments.length > 0, typeof arguments[0][@@iterator] === 'undefined' | |
dict = new Dict({ "a": 1, "b": 2, "c": 3 }) | |
// arguments.length === 1, typeof arguments[0][@@iterator] === 'undefined' | |
dict.set({ | |
"a": 1, | |
"b": 2, | |
"c": 3 | |
}); | |
// arguments.length === 1, typeof arguments[0][@@iterator] !== 'undefined' | |
dict.set(range(1, 10).map(i => [alphabet[i], i])); | |
dict.set({ toString() { return "a" } }, 1); // throws | |
dict.set("a", 1); // sets a => 1 | |
dict.set("a") // throws |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment