Js 2
Js 2
1.
Indexed Collection:
2.
1. Arrays in JavaScript are zero-indexed, meaning the first element is at index 0, the
second at index 1, and so on.
2. You can access elements using their index, for example, array[0] returns the first
element.
3.
Dynamic Size:
4.
1. Arrays in JavaScript are dynamic, meaning you can add or remove elements without
specifying the size of the array beforehand.
2. The size of the array automatically adjusts as elements are added or removed.
5.
Ordered Data:
6.
1. The order in which elements are inserted into the array is maintained.
2. You can easily rearrange elements by changing their index positions.
7.
Heterogeneous Elements:
8.
1. JavaScript arrays can store different types of data in the same array. For example,
an array can contain numbers, strings, objects, and even other arrays (nested
arrays).
1.
Properties:
2.
Common Methods:
4.
Types of Arrays
1. Single-Dimensional Array:
1. The simplest form of an array where all elements are stored in a single list.
2. Multidimensional Array:
Array Limitations
1.
Performance:
2.
3.
Sparse Arrays:
4.
1. JavaScript allows creating sparse arrays where not all indices have assigned values,
which can lead to unexpected results when performing operations on such arrays.
5.
6.
1. Unlike some programming languages, JavaScript arrays do not enforce data type
consistency, meaning you can mix different data types in a single array, which can
sometimes lead to confusion or bugs.
Typed Arrays: