Skip to main content
added 16 characters in body
Source Link
nderscore
  • 5k
  • 16
  • 40

JavaScript

Unfortunately, JavaScript does not support the square root symbol for function names. Instead, we can use some other Unicode alphabet character to represent a square root function.

In this example I'll use .

Once we have a valid symbol to use, we can use the Math object to generate a square root function.

var ᕂ = (function sqrt(_generator_){ return _generator_[arguments.callee.name]; }(Math)); ᕂ(2); // 1.4142135623730951 ᕂ(100); // 10 ᕂ(1337); // 36.565010597564445 

It's simple! :)

Of course, it would be easier to just use var ᕂ = Math.sqrt;

Unfortunately, JavaScript does not support the square root symbol for function names. Instead, we can use some other Unicode alphabet character to represent a square root function.

In this example I'll use .

Once we have a valid symbol to use, we can use the Math object to generate a square root function.

var ᕂ = (function sqrt(_generator_){ return _generator_[arguments.callee.name]; }(Math)); ᕂ(2); // 1.4142135623730951 ᕂ(100); // 10 ᕂ(1337); // 36.565010597564445 

It's simple! :)

Of course, it would be easier to just use var ᕂ = Math.sqrt;

JavaScript

Unfortunately, JavaScript does not support the square root symbol for function names. Instead, we can use some other Unicode alphabet character to represent a square root function.

In this example I'll use .

Once we have a valid symbol to use, we can use the Math object to generate a square root function.

var ᕂ = (function sqrt(_generator_){ return _generator_[arguments.callee.name]; }(Math)); ᕂ(2); // 1.4142135623730951 ᕂ(100); // 10 ᕂ(1337); // 36.565010597564445 

It's simple! :)

Of course, it would be easier to just use var ᕂ = Math.sqrt;

Source Link
nderscore
  • 5k
  • 16
  • 40

Unfortunately, JavaScript does not support the square root symbol for function names. Instead, we can use some other Unicode alphabet character to represent a square root function.

In this example I'll use .

Once we have a valid symbol to use, we can use the Math object to generate a square root function.

var ᕂ = (function sqrt(_generator_){ return _generator_[arguments.callee.name]; }(Math)); ᕂ(2); // 1.4142135623730951 ᕂ(100); // 10 ᕂ(1337); // 36.565010597564445 

It's simple! :)

Of course, it would be easier to just use var ᕂ = Math.sqrt;