You can use this code :
const arr = [1,2,3,4,5,6,7,8,9];
const newArr = [];
while(arr.length) newArr.push(arr.splice(0,3));
console.log(newArr);
More Related Contents:
- compare each 5 numbers of two array [closed]
- fetch first element of every string in array using javascript [closed]
- Convert string into several integer arrays [duplicate]
- How to get all the values associated with an object in array?
- Sort array of objects by single key with date value
- How to group by and sum an array of objects? [duplicate]
- Group objects by multiple properties in array then sum up their values
- Javascript swap array elements
- How to add an object to an array
- Check if an array is empty or exists
- How can I check if the array of objects have duplicate property values?
- GetElementByID – Multiple IDs
- Difference and intersection of two arrays containing objects
- How can I reverse an array in JavaScript without using libraries?
- What is the most efficient way to sort an Html Select’s Options by value, while preserving the currently selected item?
- Remove all falsy values from an array
- Sort array containing objects based on another array [duplicate]
- javascript function inArray
- traversing through JSON string to inner levels using recursive function
- In JavaScript, what is the best way to convert a NodeList to an array?
- Do loops check the array.length every time when comparing i against array.length?
- Big O of JavaScript arrays
- Difference between using Array.isArray and instanceof Array
- weird array behaviour in javascript [duplicate]
- How to set DOM element as first child?
- Trying to solve symmetric difference using Javascript
- Strings as keys of array
- What does [] mean in JavaScript?
- Array Length returns 0
- Should negative indexes in JavaScript arrays contribute to array length?