how to know how many pixels of page be scrolled javascript

JavaScript
window.onscroll = function (e) {
    console.log(window.scrollY); // Value of scroll Y in px
}; $(window).scroll(function() {
     // use the value from $(window).scrollTop(); 
 });
Source

Also in JavaScript: