Linked Questions

14 questions linked to/from Array() vs new Array()
4 votes
0 answers
98 views

Array function could called as a function like Array() or as constructor new Array(). Is there any difference between these 2 calling method?
Thomson's user avatar
  • 21.9k
1 vote
0 answers
78 views

Usage of the var myArray = Array(10).fill(0); and var myArray = new Array(10).fill(0); seemingly return the same result. Are there any differences between these two expressions? When should you use ...
User 5842's user avatar
  • 3,049
-3 votes
2 answers
83 views

Array(3), result: { length: 3__proto__: Array(0) } There is no index 0, 1, 2... But Array.call(null, Array(3)) has, { 0: undefined, 1: undefined, 2: undefined, length: 3, __proto__: Array(0) } I ...
-1 votes
1 answer
67 views

Why are these two statements the same in JavaScript? var a = new Array(5); var a = Array(5); Or, if they are not the same, what is different about them? Basically if I assign a to a different ...
Gaurav's user avatar
  • 133
1412 votes
56 answers
2.9m views

I have been reading online and some places say it isn't possible, some say it is and then give an example and others refute the example, etc. How do I declare a 2 dimensional array in JavaScript? (...
886 votes
46 answers
691k views

What is the most efficient way to create an arbitrary length zero filled array in JavaScript?
dil's user avatar
  • 9,062
970 votes
20 answers
940k views

What's the real difference between declaring an array like this: var myArray = new Array(); and var myArray = [];
597 votes
13 answers
123k views

In another question, a user pointed out that the new keyword was dangerous to use and proposed a solution to object creation that did not use new. I didn't believe that was true, mostly because I've ...
212 votes
6 answers
421k views

I'm having trouble either declaring or using a boolean array in Typescript, not sure which is wrong. I get an undefined error. Am I supposed to use JavaScript syntax or declare a new Array object? ...
user avatar
19 votes
6 answers
25k views

In python you can do: arr = [1,2,3] * 3 print(arr) output: [1,2,3,1,2,3,1,2,3] Is there a concise way of doing this in java script? The best I can think of is something like: let arr2 = [...arr, ......
Oamar Kanji's user avatar
  • 2,274
1 vote
0 answers
252 views

What is the difference between these two way of initializing an array in modern javascript environment (in ES6 spec) ? const arr1 = new Array(3); const arr2 = Array(3); They look same running in ...
Megan610's user avatar
1 vote
3 answers
122 views

What the different if both of them call the constructor "Array" and generate an object? I know that we lost this if we create some object without new: function Animal(name) {this.name = name} var ...
rel1x's user avatar
  • 2,441
1 vote
1 answer
78 views

I've been playing around with generating image filters using canvas, and I was attempting to improve speed by preallocating an entire matrix from the beginning. This code was the first thing that I ...
Potter's user avatar
  • 643
0 votes
2 answers
82 views

function Person(name, age, gender) { this.name = name; // run } function PersonSafe(name) { if (!(this instanceof arguments.callee)) return new PersonSafe(name) this.name = name; //...