4

Given a 2D array, a[m][n] where m,n > 0, how do I access specific portions of that array (as I would in Matlab or Python, for example):

a[2:5][3:]

I realize that the slice() command works for one dimensional arrays but I can't get it to do what I want with higher dimensions.

Is this (easily) possible within Javascript?

2
  • Check this: stackoverflow.com/questions/966225/… Commented Apr 10, 2013 at 2:12
  • @bksi Thanks, but I know how to make an array. Commented Apr 10, 2013 at 2:16

1 Answer 1

6
a.slice(2,3).map(function(m) {return m.slice(3);});

Assumes relatively up-to-date browser and/or shim.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.