JSFiddle - React, Tailwind, and code Playground

by Manoj Bhardwaj

JavaScript

let ArrayList   =  ['a','b','c','d','e','f'];

let Method1 = ArrayList;  // Referenced arrayList by another variable 
ArrayList= []; // Empty the array 
console.log(Method1); // Output ['a','b','c','d','e','f']


let Method2  = ArrayList;  // Referenced arrayList by another variable 
ArrayList.length = 0; // Empty the array by setting length to 0
console.log(Method2 ); // Output []