You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While reviewing the specifications of TypedArray.prototype.indexOf (ECMA-262 § 23.2.3.17) and Array.prototype.indexOf (ECMA-262 § 23.1.3.17), I noticed a difference in the way ToString(𝔽(k)) is handled.
The difference is that Array.prototype.indexOf stores the result of ToString(𝔽(k)) in a variable Pk using let Pk = ! ToString(𝔽(k)), whereas TypedArray.prototype.indexOf does not seem to follow this pattern.
Array.prototype.indexOf
TypedArray.prototype.indexOf
Is this difference intentional, or is it simply a matter of whether or not the result is assigned to a variable?
If it’s the latter, wouldn’t it be better to standardize the approach? It seems that using Pk to store the result is preferred, so I think it would be better to align with that. What do you think?
Also, this same issue applies to lastIndexOf as well.
The text was updated successfully, but these errors were encountered:
Thank you for the well-written issue! This difference should be inconsequential. ! ToString(𝔽(k)) is infallible and unobservable, so whether it appears once or twice is exactly the same for conformance purposes. I would be willing to accept a PR that makes these steps mirror each other (in either direction) for consistency.
Thank you for the well-written issue! This difference should be inconsequential. ! ToString(𝔽(k)) is infallible and unobservable, so whether it appears once or twice is exactly the same for conformance purposes.
First of all, I’m glad to know this. As I expected.
I would be willing to accept a PR that makes these steps mirror each other (in either direction) for consistency.
Since the behavior doesn’t change, it’s not really a problem, but since it’s part of the specification, I was a bit curious about it.
Either way is fine, but I think I’d prefer to modify it so that pk is used instead of calling it multiple times!
While reviewing the specifications of TypedArray.prototype.indexOf (ECMA-262 § 23.2.3.17) and Array.prototype.indexOf (ECMA-262 § 23.1.3.17), I noticed a difference in the way ToString(𝔽(k)) is handled.
The difference is that Array.prototype.indexOf stores the result of ToString(𝔽(k)) in a variable Pk using
let Pk = ! ToString(𝔽(k))
, whereas TypedArray.prototype.indexOf does not seem to follow this pattern.Is this difference intentional, or is it simply a matter of whether or not the result is assigned to a variable?
If it’s the latter, wouldn’t it be better to standardize the approach? It seems that using Pk to store the result is preferred, so I think it would be better to align with that. What do you think?
Also, this same issue applies to lastIndexOf as well.
The text was updated successfully, but these errors were encountered: