Created
September 26, 2014 19:23
-
-
Save mlms13/a469b4b4e0f9501d8fe1 to your computer and use it in GitHub Desktop.
Why type-checking (even in an environment like Phantom) is virtually impossible in Javascript
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
var foo = { | |
filter: function () {} | |
}; | |
var bar = []; | |
// return filtered array or object | |
function filterer(baz) { | |
return baz.filter(); | |
} | |
// call filterer with an object that has a `filter` function | |
filterer(foo); | |
// on some user interaction that wouldn't be executed by phantom, | |
// call `filterer` with a completely different type of argument | |
// that may or may not have a `filter` function | |
document.querySelector('#some-button').addEventListener('click', function () { | |
filterer(bar); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment