library: Support external libraries that modify Array.prototype

While a somewhat-dangerous practice, existing users do do this,
and we shouldn't abort on it. Using hasOwnProperty is a simple
way to make sure we're checking the dense array itself, not the
prototype.