0

What is the mean of this in JavaScript

arr=[]

10th Aug 2018, 7:52 PM
George S Mulbah II
George S Mulbah II - avatar
5 ответов
+ 3
Yes, it deletes all elements.
11th Aug 2018, 1:30 AM
Duncan
Duncan - avatar
+ 1
As Donna said, it's used for creating an array. If the brackets have nothing between them, you've either declared an empty array or you've emptied the contents. Declaring empty array: var arr = []; Now fill the array: arr = ["blue", "pink"]; arr[0] now = "blue" arr[1] now = "pink" Now empty the array: arr = [];
10th Aug 2018, 10:16 PM
Duncan
Duncan - avatar
+ 1
Duncan Not actually deleted though. Elements are removed from the array. For elements passed by reference (a.k.a objects), emptying the array only remove a reference to the object.
11th Aug 2018, 2:15 AM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
0
Duncan if we empty the array again does this mean that the previous element in the array will automatically be deleted
10th Aug 2018, 10:36 PM
George S Mulbah II
George S Mulbah II - avatar