Google JavaScript Style Guide advises against extending the Array.prototype
.
However, I used Array.prototype.filter = Array.prototype.filter || function(...) {...}
as a way to have it (and similar methods) in browsers where they do not exist. MDN actually provides similar example.
I am aware about Object.prototype
issues, but Array
is not a hash table.
What issues may arise while extending Array.prototype
that made Google advise against it?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…