Answers for "js ,flat"

2

Javascript flatten array of arrays

var multiDimensionArray = [["a"],["b","c"],["d"]]; //array of arrays
var flatArray = Array.prototype.concat.apply([], multiDimensionArray); //flatten array of arrays
console.log(flatArray); // [ "a","b","c","d"];
Posted by: Guest on July-25-2019
1

js ,flat

const numbers = [1, 2, [3, 4, 5, [6, 7]]];
const flatNumbers = numbers.flat(2);

console.log(flatNumbers);
Posted by: Guest on October-18-2020
0

js .flat

const arrays = [
      ["$6"],
      ["$12"],
      ["$25"],
      ["$25"],
      ["$18"],
      ["$22"],
      ["$10"]
    ];
const merge3 = arrays.flat(1); //The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
console.log(merge3);
Posted by: Guest on October-18-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language