std.string.indexOf with an optional start-at parameter?

Aleksandar Ružičić ruzicic.aleksandar at gmail.com
Sun Apr 3 14:19:21 PDT 2011


On Sun, Apr 3, 2011 at 10:56 PM, KennyTM~ <kennytm at gmail.com> wrote:
>> And javascript _does_ have true arrays, but it _doesn't_ have true
>> associative arrays (those are object literals).
>>
>
> I would not call it a true array if it is indexed by string internally.
> Anyway, this is not the main point.
>

You're right that JS arrays are not a point here, but I must again
disagree with you :)
I write Javascript code for living, so I think I know what I'm talking about:

var a = ["foo", "bar", "baz"];  // defining an array
a[0];    // "foo"
a["0"];  // this would also work, but only because JS casts "0" to
integer implicitly

there is no string indexing with arrays, only with objects
(associative arrays, maps, call it as you like):

var o = {foo: "bar", 0: "baz"};  // defining an object (a.k.a AA)
o.foo;      // "bar"
o["foo"];  // same, returns "bar"
o[0];       // "baz"   now, this just looks like indexing an array,
but it really ain't, it's property getter, but JS allows you have
numeric properties so it can be confusing, I admit.

That's all I have to say about JS arrays, won't be talking non-D anymore :)

Regards,
Aleksandar


More information about the Digitalmars-d mailing list