JavaScript operators are in the final analysis functions, but special ones! They usually use the infix notation to pass the arguments in them. So, from now on whenever you see something like this: 3 + 4 you think about it as a function predefined somewhere for you, that goes like this:
function +(a, b) { // do something fancy here and return the sum }
You can also check the operator precedence here:
PS: I tried to find where these functions are defined in the V8 engine with no luck! I wasted a lot of time doing this. The hard part is that I am not sure where and how they are defined. They might be defined, most probably, in C++ code somewhere! I am not sure, it is just a wild guess. If you know and you are able to find the operators definitions please share it with us! Thanks
2 comments
Beberone
August 21, 2017 at 2:32 pm
I’m writing here because I saw your bucket list and realized that I couldn’t comment there. Is it possible to have a comment area for that blog too?
gd
August 21, 2017 at 2:34 pm
Wish granted!