Delete All Array Elements

1 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$39.99
List Price:  $79.99
You save:  $40
€34.13
List Price:  €68.27
You save:  €34.13
£29.60
List Price:  £59.21
You save:  £29.61
CA$55.33
List Price:  CA$110.68
You save:  CA$55.35
A$60.99
List Price:  A$122.01
You save:  A$61.01
S$51.39
List Price:  S$102.80
You save:  S$51.40
HK$311.76
List Price:  HK$623.61
You save:  HK$311.84
CHF 31.91
List Price:  CHF 63.84
You save:  CHF 31.92
NOK kr401.76
List Price:  NOK kr803.63
You save:  NOK kr401.87
DKK kr254.78
List Price:  DKK kr509.62
You save:  DKK kr254.84
NZ$67.86
List Price:  NZ$135.73
You save:  NZ$67.87
د.إ146.86
List Price:  د.إ293.76
You save:  د.إ146.90
৳4,854.06
List Price:  ৳9,709.34
You save:  ৳4,855.27
₹3,526.57
List Price:  ₹7,054.03
You save:  ₹3,527.46
RM168.93
List Price:  RM337.91
You save:  RM168.98
₦60,859.02
List Price:  ₦121,733.26
You save:  ₦60,874.24
₨11,317.87
List Price:  ₨22,638.58
You save:  ₨11,320.70
฿1,281.72
List Price:  ฿2,563.77
You save:  ฿1,282.04
₺1,647.68
List Price:  ₺3,295.78
You save:  ₺1,648.10
B$216.50
List Price:  B$433.06
You save:  B$216.56
R703.37
List Price:  R1,406.91
You save:  R703.54
Лв66.79
List Price:  Лв133.61
You save:  Лв66.81
₩55,446.13
List Price:  ₩110,906.13
You save:  ₩55,460
₪133.13
List Price:  ₪266.31
You save:  ₪133.17
₱2,267.43
List Price:  ₱4,535.43
You save:  ₱2,268
¥5,894.60
List Price:  ¥11,790.68
You save:  ¥5,896.07
MX$748.42
List Price:  MX$1,497.02
You save:  MX$748.60
QR145.77
List Price:  QR291.59
You save:  QR145.81
P536.23
List Price:  P1,072.60
You save:  P536.37
KSh5,161.08
List Price:  KSh10,323.46
You save:  KSh5,162.37
E£1,940.97
List Price:  E£3,882.44
You save:  E£1,941.46
ብር5,705.37
List Price:  ብር11,412.18
You save:  ብር5,706.80
Kz36,670.83
List Price:  Kz73,350.83
You save:  Kz36,680
CLP$38,774.86
List Price:  CLP$77,559.42
You save:  CLP$38,784.55
CN¥285.24
List Price:  CN¥570.55
You save:  CN¥285.31
RD$2,522.38
List Price:  RD$5,045.39
You save:  RD$2,523.01
DA5,193.22
List Price:  DA10,387.74
You save:  DA5,194.52
FJ$90.08
List Price:  FJ$180.20
You save:  FJ$90.11
Q305.89
List Price:  Q611.87
You save:  Q305.97
GY$8,344.59
List Price:  GY$16,691.28
You save:  GY$8,346.68
ISK kr4,885.10
List Price:  ISK kr9,771.43
You save:  ISK kr4,886.32
DH362.48
List Price:  DH725.05
You save:  DH362.57
L669.45
List Price:  L1,339.06
You save:  L669.61
ден2,099.36
List Price:  ден4,199.26
You save:  ден2,099.89
MOP$320.55
List Price:  MOP$641.18
You save:  MOP$320.63
N$705.08
List Price:  N$1,410.34
You save:  N$705.25
C$1,467.92
List Price:  C$2,936.20
You save:  C$1,468.28
रु5,632.61
List Price:  रु11,266.63
You save:  रु5,634.01
S/140.49
List Price:  S/281.01
You save:  S/140.52
K166.47
List Price:  K332.99
You save:  K166.51
SAR149.97
List Price:  SAR299.98
You save:  SAR150
ZK952.25
List Price:  ZK1,904.74
You save:  ZK952.49
L173.24
List Price:  L346.53
You save:  L173.28
Kč832.17
List Price:  Kč1,664.55
You save:  Kč832.38
Ft13,394.11
List Price:  Ft26,791.57
You save:  Ft13,397.46
SEK kr375.71
List Price:  SEK kr751.53
You save:  SEK kr375.81
ARS$54,537.63
List Price:  ARS$109,088.91
You save:  ARS$54,551.27
Bs275.60
List Price:  Bs551.28
You save:  Bs275.67
COP$159,059.39
List Price:  COP$318,158.56
You save:  COP$159,099.16
₡20,209.06
List Price:  ₡40,423.19
You save:  ₡20,214.12
L1,044.97
List Price:  L2,090.21
You save:  L1,045.23
₲287,477.35
List Price:  ₲575,026.58
You save:  ₲287,549.23
$U1,605.62
List Price:  $U3,211.65
You save:  $U1,606.02
zł145.03
List Price:  zł290.10
You save:  zł145.07
Already have an account? Log In

Transcript

Now suppose that you want to delete all elements from an array. There are two easy ways to do so. The first one is just creating this array again, using foods are the equals to square buckets, empty square brackets, and semicolon. So now if I use the console, and log on I pass foods now to this console log, I am going to get an empty array. So this is the first easy way to delete all elements from an array. The second way, the second easy way to delete all elements is using the length method.

The first of all, I'm going to use the length method here on length. And I'm going to print all the number of all elements. here if I comment this out, and Save and Run, I'm going to get three and what three means is that this array as Elements 123. So the link now is three. But if I want to delete all elements mistakenly, by using the link, I would foods have been called the link. And I'm going to change that link to be zero.

Right. Now if I save and run and pass foods to the console work, I am going to get nothing an empty array because they changed the length to be zero. So we have two easy ways to delete all elements from an array either by creating the foods and then empty square brackets or by using billing and making the length of this array to be zero.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.