/    Sign up×
Community /Pin to ProfileBookmark

Those that know about Javascript

Hello it would help a lot if those that know about javascript can tell me if it is ok to do this or not. it looks like if I leave the [0] off, the script works ok since that is the only thing being used by this: <img id=”img” >

document.getElementById(‘img’).src = arr[new Date().getSeconds()][0]

But I just wanted to double check in case it ruins something with someone seeing my rotating images in the world. I know sometimes things seem ok but really aren’t for some reason. Is it fine to leave the [0] totally off the end of that line? Please let me know thank you very much for your help.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@vortexerauthorOct 02.2010 — Either way should I have a semi colon on the end of that line too?
Copy linkTweet thisAlerts:
@FangOct 02.2010 — Having [0] in the array reference would depend on the array and what you wanted to reference.

Semi-colon insertion is not strictly necessary in this case.

There are a few instances where it is required: http://bclary.com/2004/11/07/#a-7.9

http://mislav.uniqpath.com/2010/05/semicolons/
×

Success!

Help @vortexer 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,
)...