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 7789621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:21:08+00:00 2026-06-01T21:21:08+00:00

var b = document.getElementsByName(button); var l = document.getElementsByName(link); Which is the best way to

  • 0
var b = document.getElementsByName("button");
var l = document.getElementsByName("link");

Which is the best way to add the content of these two arrays into one?
I don’t want to use for loop

  • 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-01T21:21:11+00:00Added an answer on June 1, 2026 at 9:21 pm

    You can use Array.prototype.slice.call() to turn the nodeLists into real arrays and then use array operations on them to combine them

    var b = document.getElementsByName("button");
    var l = document.getElementsByName("link");
    // make both nodeLists into real arrays
    var copyB = Array.prototype.slice.call(b, 0);
    var copyL = Array.prototype.slice.call(l, 0);
    var combined = copyB.concat(copyL);
    

    Working demo: http://jsfiddle.net/jfriend00/vZ5tb/

    Or, a little briefer version:

    var copyB = Array.prototype.slice.call(document.getElementsByName("button"), 0);
    var copyL = Array.prototype.slice.call(document.getElementsByName("link"), 0);
    var combined = copyB.concat(copyL);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var brands = document.getElementsByName(brand); for(var brand in brands){ $(input[name='brand']).eq(brand).click(function(){ alert(hello22); loadDataFN(1); }); } This
I have some code doing this : var changes = document.getElementsByName(from); for (var c=0;
I have an XML document: var xml:XML = new XML(<rootNode> <head> <meta name=template content=Default
I want to add a shortcut like I type :open_my_document, it become :e /var/book/document.txt.
I have HTML code like so: function toggle_action(type) { var tabs = document.getElementsByName(action_tab) for(var
Consider this function: function validate() { var acc = document.getElementsByName('acc').value; var pass = document.getElementsByName('pass').value;
I cannot get this to work: function formvalidation() { var SiteNum= document.getElementsByName(sitesinput)[0].value; var i=1;
i am trying to use like var modelLength = document.getElementsByName(FK_BrandID)[0].text; when i try to
I am adding several entities to an object context. try { forach (var document
var thumbs = document.getElementsByTagName(img); for (var i=0; i<thumbs.length; i++) { Core.addEventListener(thumbs[i], click, function() {alert(i);});

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.