Skip to content

Instantly share code, notes, and snippets.

@quisido
Created December 12, 2018 13:27
Show Gist options
  • Save quisido/9a460676939e8b7396304ae327c47a2e to your computer and use it in GitHub Desktop.
Save quisido/9a460676939e8b7396304ae327c47a2e to your computer and use it in GitHub Desktop.
Variable length currying in JavaScript
// This cannot be true with the following statement.
addSubtract(1)(2)(3) === 0;
// This cannot be true with the preceding statement.
addSubtract(1)(2)(3)(4)(5)(6) === 5;
// This can be true:
addSubtract(1)(2)(3) + addSubtract(1)(2)(3)(4)(5)(6) === 5;
// These can be true too:
+addSubtract(1)(2)(3) === 0;
+addSubtract(1)(2)(3)(4)(5)(6) === 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment