Skip to content

Instantly share code, notes, and snippets.

@quisido
Last active April 8, 2019 14:42
Show Gist options
  • Save quisido/9d9171d13ef2fbf1076c8ec61ada4c5b to your computer and use it in GitHub Desktop.
Save quisido/9d9171d13ef2fbf1076c8ec61ada4c5b to your computer and use it in GitHub Desktop.
Variable length currying in JavaScript
const myStrObject = {
toString: function() {
return 'Str';
}
};
console.log('My object is ' + myStrObject); // 'My object is Str'
console.log(myStrObject + 297); // 'Str297'
const myNumObject = {
valueOf: function() {
return 123;
}
};
console.log('My object is ' + myNumObject); // 'My object is 123'
console.log(myNumObject + 297); // 420
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment