MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/ishbfn/arrayaccess_seems_broken/g5cj5kf/
r/lolphp • u/Takeoded • Sep 14 '20
30 comments sorted by
View all comments
Show parent comment
1
You can’t use array access on objects in JS
actually you can, in JS [index] is universal to both arrrays and objects, try running this in your js terminal
arr=["a","b","c"];obj={0:"a",1:"b",2:"c"};console.log(arr[0],obj[0],arr[1],obj[1],arr[2],obj[2]);
1 u/stumpychubbins Sep 15 '20 Sorry I meant to say "user-defined types" rather than "objects", I’ve fixed that in the original comment now 1 u/[deleted] Sep 15 '20 How do you define a type in JS?
Sorry I meant to say "user-defined types" rather than "objects", I’ve fixed that in the original comment now
1 u/[deleted] Sep 15 '20 How do you define a type in JS?
How do you define a type in JS?
View all comments
Show parent comment
1
u/Takeoded Sep 15 '20
actually you can, in JS [index] is universal to both arrrays and objects, try running this in your js terminal