Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does this create an array in JavaScript?

Tags:

javascript

I am using the following JavaScript code:

var a = [23, 34, 45, 33];

Is a considered an array of integers?

like image 890
As. Avatar asked Apr 08 '10 11:04

As.


2 Answers

Yes, a is an array. However, since Javascript isn't statically typed, it can contain other types as well, such as strings, objects, other arrays and so on. Therefore, tagging it as "an array of integers" wouldn't be right.

like image 135
Eli Bendersky Avatar answered Sep 28 '22 23:09

Eli Bendersky


JavaScript doesn't have an Integer type. It is an Array containing Numbers (but not limited to containing only Numbers)

like image 30
Quentin Avatar answered Sep 29 '22 00:09

Quentin