The read-only scrollY property of the Window interface returns the number of pixels that the document is currently scrolled vertically. This value is subpixel precise in modern browsers, meaning that it isn't necessarily a whole number. You can get the number of pixels the document is scrolled horizontally from the scrollX property.
var y = window.scrollY
NOTE : For cross-browser compatibility, use window.pageYOffset instead of window.scrollY.
On this page of the site you can watch the video online Get Scroll Position On Scroll With JavaScript with a duration of hours minute second in good quality, which was uploaded by the user Code Recorder 20 January 2021, share the link with friends and acquaintances, this video has already been watched 7,715 times on youtube and it was liked by 124 viewers. Enjoy your viewing!