Skip to content

Instantly share code, notes, and snippets.

@digitalconceptvisuals
Created July 29, 2020 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalconceptvisuals/4679829e15853fb49ece96ba7c72777b to your computer and use it in GitHub Desktop.
Save digitalconceptvisuals/4679829e15853fb49ece96ba7c72777b to your computer and use it in GitHub Desktop.
// 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