Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Array values can be assigned without a specific index by using the push() method in JavaScript. The push() method adds one or more elements to the end of an array and returns the new length of the array. Here is an example:

let fruits = [];
fruits.push("apple");
fruits.push("banana");
fruits.push("orange");

console.log(fruits); // Output: ["apple", "banana", "orange"]

In this example, the push() method is used to add three elements to the fruits array without specifying an index. The new elements are automatically assigned to the end of the array.