Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Windows 7
Desktop
5 years ago
Test name Executions per second
x * x 4607936.0 Ops/sec
Math.pow(x, 2) 2844376.2 Ops/sec
x ** 2 8545139.0 Ops/sec
y * y 4839461.5 Ops/sec
Math.pow(y, 2) 2934075.2 Ops/sec
y ** 2 8612083.0 Ops/sec
Script Preparation code:
Tests:
  • x * x

  • Math.pow(x, 2)

  • x ** 2

  • y * y

  • Math.pow(y, 2)

  • y ** 2


;