Created
November 11, 2011 17:52
-
-
Save Raynos/1358680 to your computer and use it in GitHub Desktop.
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
// optional typing for function parameters | |
// Allows you to use a string literal in front of the variable name | |
// This string literal must be a valid [[Class]] value | |
// And the function when invoked should throw a type error if the argument passed // in doesn't have the correct [[Class]] value | |
// If an argument is not passed in, the function should not throw an error | |
function Func("Function" f, "Array" arr) { | |
return f(arr); | |
} | |
// Works | |
Func(); | |
Func(function () { }); | |
Func(function () { }, []); | |
// Fails | |
Func([]); | |
Func("foo"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment