Created
November 8, 2016 19:44
-
-
Save aosalias/c76557550ea65b7a64ec7a987fed6893 to your computer and use it in GitHub Desktop.
Interview Question for JS fundamentals
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
function myBind() { | |
var args = Array.slice(arguments); | |
var func = arguments.pop() | |
var that = arguments.pop() | |
return ; | |
} | |
// currying | |
var add = function(...) { return x + y; } | |
var add3 = myBind(add, null, 3); | |
add3(4) === 7; | |
// curry 'this' | |
addThis = function(x) { return x + this.x; } | |
var add3This = myBind(addThis, {x: 3}) | |
add3This(4) === 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Potentially ask them to implement add with an arbitrary number of arguments
potentially ask them to implement a test plan