Linked Questions
87 questions linked to/from What’s the difference between "Array()" and "[]" while declaring a JavaScript array?
16
votes
3
answers
17k
views
Difference between "new Array(..)" and "[..]" in JavaScript? [duplicate]
Is
var myCars=new Array("Saab","Volvo","BMW");
and
var myCars=["Saab","Volvo","BMW"];
exactly the same ?
8
votes
3
answers
8k
views
Is it better to write: var arr=[]; than var arr=new Array();? [duplicate]
Is it better to write
var arr=[]; then var arr=new Array();
var obj={}; then var obj=new Object();
and if so, why?
I read slide lection page 36 about that idea, but no explanation was given or ...
Ben's user avatar
- 25.9k
8
votes
3
answers
2k
views
What is the difference between Array() and [] in Javascript and why would I use one over the other? [duplicate]
Possible Duplicate:
What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
In JavaScript you can create a new array like:
var arr = new Array(...
0
votes
4
answers
3k
views
What is the difference between Array(0) and array = [] [duplicate]
What is the difference between creating an array with Array(0) and array = []?
To my knowledge both are empty Array objects.
array
>>> []
Array(0)
>>> []
But when I compare them ...
3
votes
3
answers
271
views
Is there any difference between these three ways of creating an array? [duplicate]
Is there any difference between these three ways of creating an array? If not, why do the first two ways exist if they're just more code?
1:
var myCars=new Array();
myCars[0]="Saab";
myCars[...
1
vote
2
answers
807
views
Javascript Array Instantiation [duplicate]
What is the correct way on instantiate empty array in javascript?
var array=new Array();
var array=new Array;
var array=[];
All of them look same. Is there any difference?
2
votes
4
answers
183
views
whats the difference between these methods of defining arrays in javascript? [duplicate]
Possible Duplicate:
What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
What is the difference between these two methods of defining an ...
0
votes
0
answers
548
views
javascript difference between var myArray = new Array( ... ) and var myArray = ["one","two", 3]? [duplicate]
hello i a m learning the javascript and I am wondering whether you can help me understand why there are two ways to make a new array?
From book I see the author is using:
var myArray = new Array("...
1
vote
0
answers
217
views
What's the difference between using Array.of() compared with brackets [ ]? [duplicate]
For example,
let x = [1,2,3,5];
is equivalent to:
let x = Array.of(1,2,3,4,5);
(Unless I'm missing an important detail, which is why I'm asking the question)
You could also mix these with spread ......
user avatar
user3967379
0
votes
1
answer
103
views
About the definition of javascript variable [duplicate]
Possible Duplicate:
What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
var all = [];
var all = new Array();
What is the difference between ...
310
votes
34
answers
440k
views
Javascript - get array of dates between 2 dates
var range = getDates(new Date(), new Date().addDays(7));
I'd like "range" to be an array of date objects, one for each day between the two dates.
The trick is that it should handle month and year ...
331
votes
7
answers
456k
views
TypeScript: Creating an empty typed container array
I am creating simple logic game called "Three of a Crime" in TypeScript.
When trying to pre-allocated typed array in TypeScript, I tried to do something like this:
var arr = Criminal[];
which gave ...
140
votes
7
answers
198k
views
Maximum size of an Array in Javascript
Context: I'm building a little site that reads an rss feed, and updates/checks the feed in the background. I have one array to store data to display, and another which stores ID's of records that have ...
108
votes
6
answers
211k
views
Get an array of list element contents in jQuery
I have a structure like this:
<ul>
<li>text1</li>
<li>text2</li>
<li>text3</li>
</ul>
How do I use javascript or jQuery to get the text as an ...
148
votes
5
answers
57k
views
Why is arr = [] faster than arr = new Array?
I ran this code and got the below result. I curious to know why [] is faster?
console.time('using[]')
for(var i=0; i<200000; i++){var arr = []};
console.timeEnd('using[]')
console.time('using new'...