[whatwg] getElementsByClassName()

Alexey Feldgendler alexey at feldgendler.ru
Mon Oct 23 20:24:25 PDT 2006

On Tue, 24 Oct 2006 06:17:20 +0700, Joao Eiras <joao.eiras at gmail.com> wrote:

>> It's an array. Most languages support arrays. Why would there be a
>> problem?

> The question is.. is there really the need for the array ?
> Most bindings support variable arguments.

Array:   getElementsByClassName(["c1", "c2"]);
Varargs: getElementsByClassName("c1", "c2");

In the first case, there are just two more characters, but this method has two advantages that can't be ignored:
1. All languages have arrays, but not all languages support varargs.
2. It's easy to call the array version with an array that's constructed dynamically, without knowing the number of items in advance. Not all languages even with varargs support allow you to call a varargs function like that.

Alexey Feldgendler <alexey at feldgendler.ru>
[ICQ: 115226275] http://feldgendler.livejournal.com

More information about the whatwg mailing list