Concept Flow - Array Declaration and Initialization
Start
Declare Array Variable
Initialize Array with Values
Array Ready to Use
End
The flow shows declaring an array variable, initializing it with values, and then the array is ready for use.
let arr; arr = [10, 20, 30]; console.log(arr);
| Step | Operation | Array State | Pointer Changes | Visual State |
|---|---|---|---|---|
| 1 | Declare variable arr | undefined | arr -> undefined | arr: undefined |
| 2 | Initialize arr with [10, 20, 30] | [10, 20, 30] | arr -> array object | arr: [10, 20, 30] |
| 3 | Print arr | [10, 20, 30] | arr unchanged | Output: [10, 20, 30] |
| 4 | End | [10, 20, 30] | arr unchanged | Final array state: [10, 20, 30] |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| arr | undefined | undefined | [10, 20, 30] | [10, 20, 30] | [10, 20, 30] |
Array Declaration and Initialization: - Declare array variable: let arr; - Initialize with values: arr = [val1, val2, ...]; - Array stores elements in order - Access elements by index - Printing shows all elements - Uninitialized array is undefined
const arr = new Array(3);
console.log(arr);
const arr = new Array[1, 2, 3];
Pass the test and this pattern moves unknown