Nodejs Number Calculate square()

Here you can find the source of square()

Method Source Code

Number.prototype.square = function() {
  return this * this;
};

Related

  1. sin()
    Number.prototype.sin = function() {
        return Math.sin(this);
    
  2. smallerThan(num)
    Number.prototype.smallerThan = function(num) {
        return this < num;
    
  3. snap(resolution)
    Number.prototype.snap = function(resolution) {
      return Math.floor(this / resolution) * resolution;
    };
    
  4. sqrt()
    Number.prototype.sqrt = function() {
      return Math.sqrt(this);
    };
    
  5. square()
    var expect = chai.expect;
    Number.prototype.square = function () {
        "use strict";
        return this * this;
    };
    
  6. step(to, add_remove_step)
    Number.prototype.step = function (to, add_remove_step) {
      var from = this.valueOf();
      var ch = add_remove_step.match(/[\+,\-]/g)[0];
      var i = from;
      var arr = [];
      if (ch === '+') {
        while (i <= to) {
          arr.push(i);
          i = i + parseInt(add_remove_step);
    ...
    
  7. subNum(n)
    Number.prototype.subNum = function(n){
      var f_x = parseFloat(this);
      if (isNaN(f_x)){
        return false;
      f_x = Math.floor(f_x*Math.pow(10,n)+0.0001)/Math.pow(10,n);
      var s_x = f_x.toString();
      var pos_decimal = s_x.indexOf('.');
      if (pos_decimal < 0){
    ...
    
  8. succ()
    Number.prototype.succ = function() {
        return this + 1;
    };
    
  9. tan()
    Number.prototype.tan = function() {
        return Math.tan(this);