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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:30:44+00:00 2026-05-14T00:30:44+00:00

While reading a book about JavaScript I stumbled across an example: var names =

  • 0

While reading a book about JavaScript I stumbled across an example:

var names = new Array("Paul","Catherine","Steve");
var ages = new Array(31,29,34);
var concatArray;
concatArray = names.concat(ages);

My question is, why doesn’t the variable concatArray need to be define as a new Array() in order to store the concatenated data for both arrays name and ages , but when I try to treat the concatArray as an array by adding another line of code “document.write(concatArray[0])“, it works just like an array and shows me the data stored in the first element. I just wonder why I’m not declaring the concatArray as a new array, yet it still works as one.

  • 1 1 Answer
  • 1 View
  • 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-05-14T00:30:45+00:00Added an answer on May 14, 2026 at 12:30 am

    Because Javascript is dynamically typed. A variable doesn’t have a specifuc type, and an array is an object that you can assign to any variable.

    When you declare a variable without assigning it a value, it just exists with an undefined value:

    var answer;
    // now the variable exists, but it doesn't have a value
    answer = 42;
    // now the variable has the numerical value 42
    answer = "hello";
    // now the numerical value has been replaced with the string value "hello"
    answer = [];
    // now the variable contains an empty array
    answer[0] = 1337;
    // now the variable contains an array that contains an item with the value 1337
    answer = -1
    // now the array is gone and the variable contains the value -1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to php. I'm reading a book having an example about while
While reading about exception, I will always come across checked exceptions and unchecked exceptions,
I was reading about SIOF from a book and it gave an example :
Today, while I was randomly reading the JavaScript patterns O'Reilly book, I found one
I am reading a book about Javascript and jQuery and using one of the
i'm reading a book about Qt, there is an example about how to pop
While reading Joe Albahari's excellent book Threading in C# I came across the following
While reading the Hashing topic of C# in a nutshell book,i came across the
While reading Learning Perl , I came across a problem about regular expressions. In
while I was reading a javascript book, I read the following sentence. The call

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.