JavaScript - HasOwnProperty loop filter