Linked Questions

16 votes
3 answers
17k views

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=[]; 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

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 creating an array with Array(0) and array = []? To my knowledge both are empty Array objects. array >>> [] Array(0) >>> [] But when I compare them ...
tbd_'s user avatar
  • 1,318
3 votes
3 answers
271 views

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[...
Eric's user avatar
  • 2,044
1 vote
2 answers
807 views

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?
Mr.Cocococo's user avatar
  • 1,461
2 votes
4 answers
183 views

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 ...
thiswayup's user avatar
  • 2,067
0 votes
0 answers
548 views

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

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
0 votes
1 answer
103 views

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 ...
Sally Lou's user avatar
310 votes
34 answers
440k views

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

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

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 ...
addedlovely's user avatar
  • 3,194
108 votes
6 answers
211k views

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

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'...
Mohsen's user avatar
  • 66.1k

15 30 50 per page
1
2 3 4 5 6