Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// add is camelCase
// Use it like a function
function add(a, b) {
return a + b;
}
// Use it like a function
let result = add(1, 2);
console.log("result", result);
// Do NOT use it with new
// Sigh! It doesn't give an error
let unexpected = new add(1, 2);
// NOW, it gives weird result
console.log("unexpected", unexpected);
--------------------------------------
Output
--------------------------------------
result 3
unexpected add {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment