Arrays are the special type of object in JavaScript. It has an extra list of methods and properties (like .length and .forEach), and also it has a list of used indexes (integer positive number starting from zero higher). But just like any other object, it can have additional properties:
var arr = ['A', 'B']; arr.extra = 'C'; console.log(arr[0], arr[1], arr.extra); // A B C
Because of object properties can be accessed not only via dot but also via square brackets you can access any property using array-like syntax:
var obj = { extra: 'D' }; console.log(obj['extra']); // D console.log(arr['extra']); // C
Using the same syntax you can assign properties:
obj['x'] = 'E'; obj[33] = 'F'; arr['y'] = 'G'; arr[-1] = 'H'; console.log(obj.x, obj[33], arr.y, arr[-1]); // E F G H
You can safely use numbers as a property name for the object, it will automatically be converted to a string.
The only difference is when you use positive integer values for the name of the property. Those are interpreted as array indexes.
var arr = []; arr[0] = 'A'; arr[1] = 'B'; arr[-1] = 'C'; arr.forEach(value => console.log(value)) // A, B console.log(arr.length); // 2 console.log( Object.keys(arr) ); // ["0", "1", "-1"]