Nodejs Array Square square()

Here you can find the source of square()

Method Source Code

Array.prototype.square = function(){
    return this.map((element) =>  Math.pow(element,2));}
==
Array.prototype.cube = function(){
    return this.map((element) =>  Math.pow(element,3));}

Related

  1. square()
    Array.prototype.square = function(){
      return Array.from(this, x => x * x)
    
  2. square()
    Array.prototype.square = function () {
      return this.map(function(n) { 
        return n * n; 
      });
    
  3. square()
    Array.prototype.square = function () {
      return this.map(function (e) {
        return e * e;
      });
    };
    
  4. square()
    Array.prototype.square = function () {
      return this.map((item) => {
        return Math.pow(item, 2);
      });
    };
    
  5. square()
    Array.prototype.square = function(){
        return this.map(function(e){
            return (e * e);
        });
    };
    Array.prototype.cube = function(){
        return this.map(function(e){
            return (e * e * e);
        });
    ...