how to declare an empty array code example

Example 1: create empty array javascript

const myArray1 = []
// or...
const myArray2 = new Array()

Example 2: create an empty array js

let arrayName = [];

Example 3: how to make array empty

A.length = 0

Example 4: javascript declare empty array

// Variable array for a wider scope:
var arrayName = [];
// Local scope variable array:
let arrayName = [];

Example 5: create an empty array in java

public static void main(String args[])
{
    int array[] = new int[4];
    int number = 5, i = 0,j = 0;
    while (i<4){
        array[i]=number;
        i=i+1;
    }
    while (j<4){
        System.out.println(array[j]);
        j++;
    }
}

Tags:

Php Example