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
// 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