|
Answer» We have some fundamental issues with new Array() the example in detail for array constructor function as given below.
When array have more the ONE integer? var newArray = new Array(10, 20, 30, 40, 50); console.log(newArray[0]); //RETURNS 10. console.log(newArray.length); //returns 5.
When array have only one integer? var newArray = new Array(10); console.log(newArray[0]); //returns undefined console.log(newArray.length); //returns 10 because its has an error "array INDEX out of bound"; //This is the fundamental deference to need to avoid the new array(); We have some fundamental issues with new Array() the example in detail for array constructor function as given below. When array have more the one integer? var newArray = new Array(10, 20, 30, 40, 50); console.log(newArray[0]); //returns 10. console.log(newArray.length); //returns 5. When array have only one integer? var newArray = new Array(10); console.log(newArray[0]); //returns undefined console.log(newArray.length); //returns 10 because its has an error "array index out of bound"; //This is the fundamental deference to need to avoid the new array();
|