Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8022283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:13:23+00:00 2026-06-04T22:13:23+00:00

I have a JavaScript array like: [[$6], [$12], [$25], [$25], [$18], [$22], [$10]] How

  • 0

I have a JavaScript array like:

[["$6"], ["$12"], ["$25"], ["$25"], ["$18"], ["$22"], ["$10"]]

How would I go about merging the separate inner arrays into one like:

["$6", "$12", "$25", ...]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:13:25+00:00Added an answer on June 4, 2026 at 10:13 pm

    ES2019

    ES2019 introduced the Array.prototype.flat() method which you could use to flatten the arrays. It is compatible with most environments, although it is only available in Node.js starting with version 11, and not at all in Internet Explorer.

    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);
        

    Older browsers

    For older browsers, you can use Array.prototype.concat to merge arrays:

    var arrays = [
      ["$6"],
      ["$12"],
      ["$25"],
      ["$25"],
      ["$18"],
      ["$22"],
      ["$10"]
    ];
    var merged = [].concat.apply([], arrays);
    
    console.log(merged);

    Using the apply method of concat will just take the second parameter as an array, so the last line is identical to this:

    var merged = [].concat(["$6"], ["$12"], ["$25"], ["$25"], ["$18"], ["$22"], ["$10"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So in javascript I have an array that looks about like this: [{x1:0,x2:2000,y:300},{x1:50,x2:250,y:500}] And
I would like to read geographic data (logitude/latitude) from two sources into one Javascript
I have a javascript array of objects that I would like to use to
I have an array on javascript and i insert the elements on it like
I would like to sort an array of strings (in JavaScript) such that groups
I would like to have an array dynamically generated by keypress, then have different
i have a javascript array like this: array = [ {Command: SetDuration,QuestionId: 2,NewDuration: 1},
Suppose I have a Javascript array, like so: var test = ['b', 'c', 'd',
I have a javascript array: var exclude = [Santorum,Obama,Romney,Gingrich]; I have html links: <a
1) I have this Javascript array: lang=new Array(); lang[sq]=Albanian; lang[ar]=Arabic; lang[en]=English; lang[ro]=Romanian; lang[ru]=Russian; 2)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.