/    Sign up×
Community /Pin to ProfileBookmark

Problems with Array

Hi, Imagine this situation:

You have the following element of an array

array[0][3][4][3]

and you know that you have, for instance, 50 elements before this one. Knowing this number is there a way to represent the element shown above with a notation where i could use the #50?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63May 16.2003 — If I understadn your question correctly,if you put this array[0][3][4][3] an another array..:-)

then you can use that,,say you have an array that is indexed from 0 to 53 and 54th entry is the one above

someArray[54] = array[0][3][4][3];

this should work theoretically...
Copy linkTweet thisAlerts:
@CharlesMay 16.2003 — [font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Content-Script-Type" content="text/javascript">

<title>Example</title>

<script type="text/javascript">

<!--

Array.prototype.toFlattened = function () {return this.toString().split(',')}

a1 = ['one', 'two', 'three', 'four'];

a2 = ['a', 'b', 'c', 'd'];

a = [a1,a2];

alert (a.toFlattened()[5])

// ->

</script>[/font]
Copy linkTweet thisAlerts:
@cajo_vcambraauthorMay 16.2003 — It worked perfectly, thank you for your help (2 both).

?
×

Success!

Help @cajo_vcambra spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...