Skip to main content
24 events
when toggle format what by license comment
Jun 24, 2020 at 17:24 comment added Arthur Alunts @ Barmar ok I have already corrected this in my answer see 6-th answer where evrything is ok!
Jun 24, 2020 at 14:16 comment added Barmar @ArthurAlunts Array indexes go from 0 to 4, so there's no [5][5][5][5] element.
May 2, 2018 at 16:02 review Suggested edits
May 2, 2018 at 16:18
S Jul 23, 2017 at 5:58 history suggested Jake Boggs CC BY-SA 3.0
Tested in Chrome.
Jul 22, 2017 at 20:05 review Suggested edits
S Jul 23, 2017 at 5:58
Nov 29, 2015 at 7:10 history edited Barmar CC BY-SA 3.0
added 7 characters in body
Nov 29, 2015 at 2:25 review Suggested edits
Nov 29, 2015 at 4:10
May 13, 2015 at 18:10 comment added Barmar @sebastian_k He's implementing an interpreter for another language. So he's parsing its array indexing syntax and needs to implement it using JS.
May 13, 2015 at 18:08 comment added Barmar The number of dimensions is also dynamic. It could be a[index1] or a[index][index2].
May 13, 2015 at 18:07 comment added sk29910 I'm not sure I understand your point—couldn't I just go a[index1][index2][index3] if I need dynamic subscripts?
May 13, 2015 at 18:04 comment added Barmar @sebastian_k The whole point of the question is that you have a dynamic array of subscripts, you're not writing it literally.
May 13, 2015 at 17:53 comment added sk29910 Instead of getElement(a, [2, 3, 5]) you can simply write a[2][3][5].
S May 13, 2015 at 16:52 history suggested sk29910 CC BY-SA 3.0
needs a "var" in the for loop declaration to ensure that every function instance uses a separate i
May 13, 2015 at 16:07 review Suggested edits
S May 13, 2015 at 16:52
Apr 29, 2013 at 14:59 comment added Barmar @yckart Not sure what was going through my head when I wrote that, fixed it.
Apr 29, 2013 at 14:58 history edited Barmar CC BY-SA 3.0
deleted 1 characters in body
Apr 29, 2013 at 12:07 comment added yckart The getElement-function seems to be not correct, slice is not defined.
Sep 25, 2012 at 18:32 vote accept Chris
Sep 25, 2012 at 18:32 comment added Chris @Barmar Yeah, that'll do it. Thanks!
Sep 25, 2012 at 18:28 comment added Barmar See my edit for accessing elements. And it would be trivial to make the default element a parameter to the creation function.
Sep 25, 2012 at 18:27 history edited Barmar CC BY-SA 3.0
added 376 characters in body
Sep 25, 2012 at 18:23 comment added Pete One suggestion: I think null is a better default value than undefined. That way it's easy to test whether you're outside the bounds of the array or just getting an empty value. But the OP doesn't specify, so undefined might be what he/she wants.
Sep 25, 2012 at 18:21 comment added Chris I hate posting the same comment on two answers, but, like I said to @Pete: how would you access a specific element in the already-created array?
Sep 25, 2012 at 18:18 history answered Barmar CC BY-SA 3.0