R
Reactiflux

Vradhit – 11-46 Aug 2

Vradhit – 11-46 Aug 2

VVradhit8/2/2022
What is the meaning of const variable =[0] ? In js
SScriptyChris8/2/2022
variable is assigned with an array containing 0 (zero) digit
VVradhit8/2/2022
Ok we can also specify using fill method also right?
SScriptyChris8/2/2022
Yes, but in this example using .fill() method seems like an overkill
VVradhit8/2/2022
Ok thanks for the info What is the difference of declaring empty array over this 0?
SScriptyChris8/2/2022
I don't understand your question 😐 [] is an empty array and [0] is an array with zero inside
VVradhit8/2/2022
Ok so initialising with 0 and then pushing the new element will it over rite correct that 0 inside it
SScriptyChris8/2/2022
No, using .push() doesn't override anything in an array - it adds new value to the end of that array So if you used .push(2) to your variable then you would have array looking like this [0, 2]
VVradhit8/2/2022
Oh ok thanks for understanding me this concept
UUUnknown User8/3/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

Vradhit – 11-46 Aug 2

Join Server