Broccoliy
Broccoliy

Reputation: 29

How to use "^" as power in JavaScript?

I know that we can use Math.pow() as a power function. However I'm making a calculator, and the user might type "^" to do the power function. Is there any way to use "^" as a power function? Or some things like ^() will also work.

Upvotes: 2

Views: 98

Answers (1)

Michael Lorton
Michael Lorton

Reputation: 44436

Sorry, ^ means binary-exclusive-or in Javascript, and Javascript does not allow you to re-map operators.

(And you shouldn’t anyway. It would quickly become very confusing.)

Upvotes: 3

Related Questions