I would like to modify the default operators of JavaScript. For example, when you execute the following command: 2 + 2
, I would like to change what the +
does depending on whether it's even or odd (as an example).
Asked
Active
Viewed 38 times
0

Detuned
- 3,652
- 4
- 27
- 54
-
no, you can not overload operators in javascript. – Nina Scholz Jun 22 '18 at 17:51
-
@OJKwon This isn't operator overloading, since he wants to change the behavior for built-in types, not user-defined types. – Barmar Jun 22 '18 at 17:51