Closed ljharb closed 11 years ago
substring
is standard. substr
is not (which is used in line 407).
My preference for slice over substring is simply that 'abc'.substring(-1) => 'abc', while 'abc'.slice(-1) => 'c' - ie, it does something expected, instead of something unexpected - and "sometimes confusing" things imo should be avoided.
Sorry, I misunderstood that you were addressing two concerns simultaneously.
I don't feel strongly about this enough to object, although I'd just note that all my usages of both substr()
and substring()
both use the two parameter form, so it seems like they are "safe" as used. But anyway, like I said, not something I'm concerned either way with. Once I land the other merge, I'll come back and see if this will merge cleanly or not. :)
Sounds great :-)
Hmm.... "non-standard"?
This page indicates something otherwise: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
Can you provide more details on why
substring()
should be avoided? I don't have a major problem with your suggestion, but I'd like to understand the motivation better.