I want to assign some properties to an array, but only if they are array indices. Otherwise some implementations might switch the underlying structure to a hash table and I don't want that.
For example, these are array indices: "0"
, "1"
, "2"
, "3"
, "4"
, "4294967294"
But these are not: "abcd"
, "0.1"
, "-0"
, "-1"
, " 2"
, "1e3"
, "4294967295"
Is there an easy way to test if a string is an array index?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…