Home Articles/Tutorials Login Register
WebCodeLogic

Javascript Spread Operator ...

 ← Dev Articles
👍 0
👎 0

The javascript spread operator ... is a convenient way to insert an array into a second array.  Used mainly when defining the array data.  Consider the following:

/****
 * The x array is placed inside of noSpread as a child array inside.
 * noSpread array is now ['u', Array(2), 3, 7]
 ****/
let x = ['a', 2];
let noSpread = ['u', x, 3, 7];

/***
 * using the spread operator ...x
 * the spread array is now ['u', 'a', 2, 5, 6]
 ***/
 
let x = ['a', 2];
let spread = ['u', ...x, 5, 6];

 

 PHP +21  Number of articles in category PHP
 Laravel +14  Number of articles in category Laravel
 Javascript +14  Number of articles in category Javascript
 VueJS +6  Number of articles in category VueJS
 NodeJS +6  Number of articles in category NodeJS
 LAMP +5  Number of articles in category LAMP
 PostgreSQL +3  Number of articles in category PostgreSQL
 MySQL +3  Number of articles in category MySQL
 MongoDB +2  Number of articles in category MongoDB
 ImageMagick +2  Number of articles in category ImageMagick
 Database +1  Number of articles in category Database
 ReactJS +1  Number of articles in category ReactJS
 Composer +1  Number of articles in category Composer
 Bootstrap +1  Number of articles in category Bootstrap
 Blade +1  Number of articles in category Blade
  •  Most Popular

  • Use PHP Recursion to Calculate the Sum of Multi-dimensional Arrays

    AsyncNinja

     more..
  • PHP Ternary Operator ? :

    PixelCompiler

     more..
  • Upload and Resize an Image with Laravel Vue and ImageMagick

    CodeCascade

     more..
  •  Most Recent

  • JavaScript Promises and Asynchronous Handling Explained

    CodeCascade

     more..
  • JavaScript Asynchronous Programming with Promise any()

    CodeCascade

     more..
  • Master JavaScript Asynchronous Programming with Promise.allSettled()

    CodeCascade

     more..
WebCodeLogic