You can do it easily using typeof like following

For the first code block

if(typeof arr[i] === 'string'){
     arr2.push(   
     funct1(arr[i]));
}

For the second one

if(typeof arr[i] === 'number'){
      arr2.push(
      funct2(arr[i]));
    }   
Answer from PaulShovan on Stack Overflow
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Array
Array - JavaScript - MDN Web Docs
July 28, 2026 - Array elements are object properties in the same way that toString is a property (to be specific, however, toString() is a method). Nevertheless, trying to access an element of an array as follows throws a syntax error because the property name is not valid: ... JavaScript syntax requires properties beginning with a digit to be accessed using bracket notation instead of dot notation.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_arrays.asp
JavaScript Arrays
The typeof operator in JavaScript returns "object" for arrays. But, JavaScript arrays are best described as arrays. Arrays use numbers to access its "elements".
๐ŸŒ
JavaScript Tutorial
javascripttutorial.net โ€บ home โ€บ javascript tutorial โ€บ javascript arrays
JavaScript Array
August 12, 2016 - In JavaScript, an array is an order list of values; each value is called an element specified by an index. An array can hold values of mixed types.
๐ŸŒ
Mozilla
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Guide โ€บ Typed_arrays
JavaScript typed arrays - JavaScript | MDN
Typed arrays are not intended to replace arrays for any kind of functionality. Instead, they provide developers with a familiar interface for manipulating binary data. This is useful when interacting with platform features, such as audio and video manipulation, access to raw data using WebSockets, and so forth. Each entry in a JavaScript typed array is a raw binary value in one of a number of supported formats, from 8-bit integers to 64-bit floating-point numbers.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ types-of-arrays-in-javascript
Types of Arrays in JavaScript - GeeksforGeeks
July 23, 2025 - A JavaScript array can be classified into multiple types: ... A numeric array is an array that contains only the numeric values as elements that are stored at different memory locations but in a consecutive manner.
Find elsewhere
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ TypedArray
TypedArray - JavaScript - MDN Web Docs
July 28, 2026 - All typed arrays except Int8Array, Uint8Array, and Uint8ClampedArray store each element using multiple bytes. These bytes can either be ordered from most significant to least significant (big-endian) or from least significant to most significant (little-endian).
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 47955379 โ€บ is-there-a-type-for-an-array-of-specific-type-in-javascript
Is there a type for an array of specific type in javascript? - Stack Overflow
* --------------------------------- * using 'Object(e)' so that the check works for primitives, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object */ return Object.getPrototypeOf(Object(e)) === type.prototype; }); }; console.log(checkArrayType([1,2,3,4], Number)); // true console.log(checkArrayType(['hello', 10], String)); // false console.log(checkArrayType([[1, 2.5], ['a', 'b']], Array)); // true console.log(checkArrayType([null, null, null, null], null)); // true console.log(checkArrayType([new String('hello'), new String('world')], Object)); // false var Foo = function Foo(){}; console.log(checkArrayType([new Foo(), new Foo()], Foo)); // true console.log(checkArrayType({a: null}, null)); // throws error console.log(checkArrayType([], 'abc')); // throws error
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ the-javascript-array-handbook
The JavaScript Array Handbook โ€“ JS Array Methods Explained with Examples
May 21, 2021 - This means that you can create an array with elements of type String, Boolean, Number, Objects, and even other Arrays.
๐ŸŒ
Mozilla
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Guide โ€บ Indexed_collections
Indexed collections - JavaScript - MDN Web Docs - Mozilla
2 weeks ago - The code below uses an arrow function to return the type of each array element (this uses object destructuring syntax for function arguments to unpack the type element from the passed object). The result is an object that has properties named after the unique strings returned by the callback.
๐ŸŒ
W3schools
w3schools.dev โ€บ js โ€บ js_arrays.asp
JavaScript Arrays - W3Schools
The typeof operator in JavaScript returns "object" for arrays. But, JavaScript arrays are best described as arrays. Arrays use numbers to access its "elements".
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_typed_arrays.asp
JavaScript Typed Arrays
Typed arrays store elements of Fixed Types like 8-bit integers or 32-bit numbers. ... Typed Arrays were designed to provide an efficient way to handle binary data, unlike traditional JavaScript arrays which can hold elements of mixed data types.
๐ŸŒ
CodinGame
codingame.com โ€บ playgrounds โ€บ 6181 โ€บ javascript-arrays---tips-tricks-and-examples
JavaScript Arrays - tips, tricks and examples
CodinGame is a challenge-based training platform for programmers where you can play with the hottest programming topics. Solve games, code AI bots, learn from your peers, have fun.
๐ŸŒ
Built In
builtin.com โ€บ software-engineering-perspectives โ€บ javascript-array-typeof
JavaScript Typeof for Data Types: Array, Boolean and More | Built In
Type checking with typeof is especially useful for most of the primitive types in JavaScript, including undefined, string and number. On the other hand, Array, Date and Regular Expressions are native objects that are not differentiated from each other by typeof.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript-arrays
JavaScript Arrays | GeeksforGeeks
In JavaScript, an array is an ordered list of values. Each value is called an element, and each element has a numeric position in the array, known as its index. Arrays in JavaScript are zero-indexed, meaning the first element is at index 0, ...
Published: February 10, 2025
๐ŸŒ
HackerNoon
hackernoon.com โ€บ work-with-javascript-arrays-like-a-boss-97207a042e42
Work with JavaScript arrays like a boss | HackerNoon
July 2, 2017 - An element inside an array can be of any type, and different elements of the same array can be of different types : string, boolean, even objects or other arrays. This means that itโ€™s possible to create an array that has a string in the first ...
๐ŸŒ
Code Institute
codeinstitute.net โ€บ blog โ€บ javascript โ€บ javascript arrays
Javascript Arrays: A Guide - Code Institute Global
December 20, 2022 - Since JavaScript arrays do not refer to associative arrays, it is impossible to access array items using random strings as indexes; instead, nonnegative numbers (or their corresponding string forms) must be used. Square brackets are used to indicate how to obtain an arrayโ€™s elements.
๐ŸŒ
Wikibooks
en.wikibooks.org โ€บ wiki โ€บ JavaScript โ€บ Arrays
JavaScript/Arrays - Wikibooks, open books for an open world
December 20, 2007 - (But there are also typed arrays where all values have the same data type.) When you create an array, you do not need to declare a size - but you can. Arrays grow automatically. This makes arrays very convenient to use, but not well-suited for applications in numerical analysis. Because arrays are objects, they have methods and properties you can invoke at will. For example, the .length property indicates how many elements are currently in the array.