I found the cause. There is a module that deep clones complex objects so they can be restored in the future. Can you spot the error in this recursive loop?

function cloneObject(src) {
    let target = {};
    target.__proto__ = src.__proto__;
    for (let prop in src) {
        if (src.hasOwnProperty(prop)) {
            // if the value is a nested object, recursively copy all it's properties
            if (isObject(src[prop])) {
                target[prop] = cloneObject(src[prop]);
            } else {
                target[prop] = src[prop];
            }
        }
    }
    return target;
}

When someArray goes through the cloneObject() function, it creates a new object called Array that does not retain true array properties but instead converts it into an object with proto='Array' (as @CRice pointed out) and nothing more. To fix this we really need to rework the cloneObject function to preserve arrays. This is the corrected deep copy cloneObject function I am now using:

function cloneObject(src) {
    let target = {};
    var isArray = Array.isArray(src);
    if(isArray){
        target = [];
    } else {
        target.__proto__ = src.__proto__;
    }

    for (let prop in src) {
        if (src.hasOwnProperty(prop)) {
            // if the value is a nested object, recursively copy all it's properties
            if (isObject(src[prop])) {
                var propertyValue = cloneObject(src[prop]);
            } else {
                var propertyValue = src[prop];
            }
            
            // if src was an array
            if(isArray){
                target.splice(prop, 0, propertyValue);
            } else {
                target[prop] = propertyValue;
            }
        }
    }
    return target;
}
Answer from Zachary on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › types-of-arrays-in-javascript
Types of Arrays in JavaScript - GeeksforGeeks
July 23, 2025 - A string array contains only the string elements which means it has all the memory blocks filled with the string values that can be accessed using the indexing syntax. Example: The below code explains the string array implementation. ... const strArr = ['GeeksforGeeks', 'JavaScript', 'TypeScript']; console.log("String Array: ", strArr); console.log("First element: ", strArr[0]); ... An array of arrays or the 2D array contains the multiple arrays as its elements that are stored at different memory locations.
🌐
W3Schools
w3schools.com › js › js_arrays.asp
JavaScript Arrays
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate ... An Array is an object type designed for storing data collections. ... Elements: An array is a list of values, known as elements.
Discussions

Are there different types of Arrays in JavaScript? - Stack Overflow
This is the console output of two different "arrays" made up of the same strings. I do not know how they originated (there is lots of code that I did not write) but I believe only Object2... More on stackoverflow.com
🌐 stackoverflow.com
JavaScript arrays arent actually arrays at all?
Statically typed languages care a lot about the things that are in the array being of the same type. Dynamically typed languages? Not so much. You can imagine JS arrays as being arrays of references to stuffs ^^ More on reddit.com
🌐 r/learnprogramming
78
47
February 12, 2026
Why Javascript returns "Array" Data structure as Object. Please explain why Array in JavaScript can store multiple data types.
JavaScript doesn’t do type checking, you can put whatever you want in an array. However of course this can lead to errors and bugs. But that’s the trade off to using JavaScript a simple language that lets you program (no type checking) but this simplicity can lead to bugs or errors. If you really want type checking then I suggest you get typescript, it’s a super set of JavaScript that enforced type checking. More on reddit.com
🌐 r/learnjavascript
13
24
October 1, 2021
Is it possible to create an array union types as values?

If you want to enumerate over a union type, you're best off starting with the array and creating the type from that.

This will work, for instance:

// define the array first, note the const
const FruitValues = ["apple", "banana"] as const;

// this magic incantation will create a union from that array
type Fruits = (typeof FruitValues)[number];

const fruitBasket: Fruits[] = [];
FruitValues.forEach(Fruit => fruitBasket.push(Fruit));
console.log(fruitBasket);
More on reddit.com
🌐 r/typescript
22
12
June 8, 2021
🌐
Medium
medium.com › @julienetienne › different-types-of-arrays-in-javascript-and-when-to-use-them-77f7843b71de
Different Types of Arrays in JavaScript + When to Use Them | by Julien Etienne | Medium
February 8, 2024 - Generic: It’s not tied down to a particular data type. It can be used to store any binary data, whether it represents integers, unsigned integers, floats, unsigned floats and strings. Raw: The representation of ArrayBuffer in JavaScript is consistent with physical memory there is no metadata or transformations.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript - MDN Web Docs
2 days ago - (When those characteristics are undesirable, use typed arrays instead.) JavaScript arrays are not associative arrays and so, array elements cannot be accessed using arbitrary strings as indexes, but must be accessed using nonnegative integers (or their respective string form) as indexes. JavaScript arrays are zero-indexed: the first element of an array is at index 0, the second is at index 1, and so on — and the last element is at the value of the array's length property minus 1.
🌐
Code Institute
codeinstitute.net › blog › javascript › javascript arrays
Javascript Arrays: A Guide - Code Institute Global
December 20, 2022 - One variable name is used to access the JavaScript array. To access specific array elements, utilise the index values. An array’s data is often processed using a loop statement, which changes the index value inside the loop’s body to access all of the array’s elements. Processing information in an array requires a few statements. As a result, employing arrays to process data in a programme makes it smaller. There are four types of JavaScript Arrays.
🌐
Electronic Clinic
electroniclinic.com › js-array-types-of-array-in-javascript-and-their-uses
Js Array, Types of Array in JavaScript and their uses
April 4, 2021 - Tags4 and 3 in one dimensional array which compute the factorial of the values of each element of Js array and print the result 6 7 8 Array in JavaScript Declaring One-Dimensional Js array Dense Array Dense JavaScript Array Dense Js Array Displaying Data From Js array Example write JavaScript code to enter integer type data into an array and then to print the values in reverse order Example write JavaScript code to enter values into one-dimensional array.
Find elsewhere
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Arrays
An array is a special kind of object. The square brackets used to access a property arr[0] actually come from the object syntax. That’s essentially the same as obj[key], where arr is the object, while numbers are used as keys. They extend objects providing special methods to work with ordered collections of data and also the length property. But at the core it’s still an object. Remember, there are only eight basic data types in ...
🌐
Quora
quora.com › Can-a-JavaScript-array-contain-different-types
Can a JavaScript array contain different types? - Quora
Answer (1 of 3): Yes, an Array can contain anything (an “object” type, a “number” type, a function, null, undefined, etc.) because JavaScript is not a strongly typed language. BUT, internally the engine may use a typed array for optimization, and if the assumption is not correct it ...
🌐
Reddit
reddit.com › r/learnprogramming › javascript arrays arent actually arrays at all?
r/learnprogramming on Reddit: JavaScript arrays arent actually arrays at all?
February 12, 2026 -

So I have been learning computer science in college and getting specialized in web development just so I can get a better chance of landing an entry level job and I ran across something that I have been confused about. So in my understanding from my CS courses, an array is a contiguous composite data structure which holds homogeneous values which are ordered with an index. However in JS, arrays are composite data structures which hold heterogeneous values and are ordered with an index. Would an array in JS be closer to a record as far as data structures go or am I putting the cart before the horse in the importance of the allowance of more than one data structure? Is it more important that arrays are index-based by their definition more than it is important that they are homogeneous?

Any and all help would be great, thanks!!

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › Arrays
Arrays - Learn web development | MDN
May 21, 2026 - Note: We've said it before, but just as a reminder — JavaScript starts indexing arrays at zero! Note that an array inside an array is called a multidimensional array. You can access an item inside an array that is itself inside another array by chaining two sets of square brackets together.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript arrays
JavaScript Array
November 15, 2024 - For example, you can have an array that stores elements with the types number, string, boolean, and null. Second, the size of an array is dynamic and auto-growing. In other words, you don’t need to specify the array size up front.
🌐
Wikibooks
en.wikibooks.org › wiki › Common_JavaScript_Manual › Data_types_-_Arrays
Common JavaScript Manual/Data types - Arrays - Wikibooks, open books for an open world
Array.slice(start,end) - returns array with elements of Array from start index to end index without element with index end.
🌐
Simplilearn
simplilearn.com › home › resources › software development › javascript tutorial: learn javascript from scratch › all you need to know about javascript arrays
All You Need to Know About JavaScript Arrays
April 26, 2026 - The article explains what are arrays in JavaScript, array operations, array methods, map, reduce and filter. So, click here to learn more about JavaScript arrays.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Pressbooks
ecampusontario.pressbooks.pub › webdev › chapter › arrays-and-objects
JavaScript Arrays and Objects – Full Stack Web Development for Beginners
Write simple JavaScript programs using arrays, objects, and arrays of objects. Like most programming languages, JavaScript supports an indexed data type (called an array) for storing ordered lists of values.
🌐
Javatpoint
javatpoint.com › javascript-array
JavaScript array - javatpoint
JavaScript array object tutorial with example, array literal, array by new keyword, array by constructor and so forth
🌐
W3Schools
w3schools.com › jsref › jsref_obj_typed_array.asp
JavaScript Typed Arrays
Typed Array is an ECMAScript6 (ES6 2015) feature. JavaScript 2015 is supported in all browsers since June 2017:
🌐
JavaScript Institute
javascriptinstitute.org › javascript-tutorial › arrays-in-javascript
Arrays in JavaScript - JavaScript Institute
Hence the need for the JavaScript code to be able to easily manipulate raw binary data in typed arrays. Implementation of typed arrays in JavaScript provides buffers and views. A buffer is an object representing chunk of data with no functionality to access its content.