Also, `!Object.isUndefined(window.pageYOffset)` instead of `window.pageYOffset !== undefined`.