String.charAt()

Harri Porten porten at kde.org
Sat Apr 16 19:53:55 CEST 2005


Hi!

I just saw a comment in JavaScriptCore's String implementation that
confused by slightly:

 case CharAt:
    // Other browsers treat an omitted parameter as 0 rather than NaN.
    // That doesn't match the ECMA standard, but is needed for site compatibility.
    dpos = a0.isA(UndefinedType) ? 0 : a0.toInteger(exec);

I think you can remove that comment as it is wrong. It's not only other
browsers but also the standard that treat a missing parameter as 0.
That's because toInteger(undefined) is supposed to return 0 (9.4/2). You
might want to reevaluate how your toInteger() implementation works or at
least check all places where it is used.

Harri.



More information about the Khtml-devel mailing list