+ 1

Whats the need of "[ ]"??

I wrote the following code and when I called 'val.name' it gave me an uncaught error for using '.' I saw in a solution that it was enclosed in sq brackets [ ] and tried the same and it worked. But I can't make out what exactly does the sq brackets do. Please help if u know that. https://code.sololearn.com/WkJP6kfWxV99/?ref=app

19th Aug 2020, 11:30 AM
Deven
Deven - avatar
3 Réponses
+ 4
That syntax is called "Computed Properties". I think it's well explained here: https://www.sololearn.com/learn/JavaScript/2975/
19th Aug 2020, 2:33 PM
Kevin ★
+ 1
That use to form list.
19th Aug 2020, 12:59 PM
Karan Mailaram
Karan Mailaram - avatar
0
"[ ]" this means list, in which we can put any integers and string.
20th Aug 2020, 1:06 PM
Karan Mailaram
Karan Mailaram - avatar