Results 1 to 8 of 8
Thread: Tutorial: Arrays in JavaScript
-
December 10th, 2011, 10:50 PM #1
Tutorial: Arrays in JavaScript
Hi everyone,
This is the happening place to discuss all things related to the Arrays in JavaScript tutorial.
Cheers,
Kirupa
-
December 11th, 2011, 12:54 AM #2Perhaps ironically, the discussion that your link references kind of deconstructs the idea that using new isn't recommended "in general". Douglas Crockford's opinions and best practices aren't taken seriously by everybody. Brendan Eich, for example, can often be seen opposing Crockford's advice.
Originally Posted by kirupa in the tutorial
In my opinion, [] vs. new Array is a non-issue, in the sense that I'd never feel the need to convert somebody else's use of one form to the other, and I've never seen anybody accidentally use new Array(5) to mean [5]. I've also never seen a situation where someone overrode Array. If it were to happen accidentally, you would not feasibly be able to continue working on your site/app without immediately noticing that related uses of Array were causing errors.
I'm not happy with your decision to recommend against that use case, although I think it's a trivial part of the tutorial.
-
December 11th, 2011, 06:28 AM #3
I've found that 99% of "best practices" are 99% subjective.
Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
-
December 11th, 2011, 03:17 PM #4
Kril - that is a fair point. I will describe both cases.
-
December 11th, 2011, 03:53 PM #5
-
December 11th, 2011, 05:36 PM #6
I have edited the tutorial to mention both cases along with a blurb mentioning my preference for the array literal syntax.
-
December 17th, 2011, 12:36 PM #7
What about the slice and splice functions? Especially the splice function might be of good use when using arrays.
AS2 / AS3 / JS / JQUERY / (X)HTML / HTML5 / CSS / CSS3 / PHP
-
December 20th, 2011, 02:37 AM #8
Swooter - I will add that in a revision

Reply With Quote


Bookmarks