-
Notifications
You must be signed in to change notification settings - Fork 3.9k
use of 'pageYOffset / pageXOffset' without 'window.' in 'coordinates' article #1599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I personally didn't have problem with that as early in the tutorial author mentioned it several times that global properties can be used as window.property and just property. Although I'm neutral about scrollY/scrollX being mentioned. |
Well, I thought it would be better to mention it. |
I updated references to use |
I think that might forestall some confusion, though what I might suggest instead, perhaps, is to have the code as it was, but with a note below along the lines of "as you may recall from (earlier article), the properties of the |
I use Is there something that I miss? |
OK. I thought from the original code here that not using |
Usually it's better to use In the tutorial it's definitely better to be explicit, I suppose. |
Good to know. In https://javascript.info/global-object, where you talk about the global |
And yes, explicit is usually better. And a certain amount of repetition. I remember once I had a teacher in a course on partial differential equations, and he had a way of repeating some little salient phrase at the end of an explanation, almost as if he was talking to himself, that often made the crucial difference between understanding what he was saying or losing it. |
Yes, for properties of browser window I use Functions such as In node.js there should be an import, and then import fetch from ...
fetch(...).then(...) So such usage (without Browser window properties on the other hand, are not compatible by default. There's no browser window in Node.js (unless emulated, then we're good to put |
In the article: https://javascript.info/coordinates,
The code:
uses
pageYOffset
&pageXOffset
without prefixing them withwindow.
, even though all previous discussions of the properties did use thewindow.
prefix.The
window
object was, I'm pretty sure, discussed in an earlier article, but I think it would be good to mention with this example, or, maybe better, in the previous article https://javascript.info/size-and-scroll-window#page-scroll howwindow
properties are global variables, so that if one wants,window.
can be omitted.Additionally, in the interest of understanding code that one might encounter, perhaps a mention in the same place where
window.pageYOffset
et al are introduced that thewindow
properties "scrollY
" and "scrollX
" are identical to "pageYOffset
" and "pageXOffset
" (though apparently they have less cross-browser compatibility, so are not recommended) would be good.The text was updated successfully, but these errors were encountered: