当循环内没有语句时,这个 while 循环如何帮助函数

问题描述 投票:0回答:0

while 循环在这里是如何工作的,而我们没有在其中给出任何语句。 我想知道这个循环如何帮助运行

function activeMenu()
.

const links = document.querySelectorAll(".nav-item");
const section = document.querySelectorAll("section");

function activeMenu() {
  let len = section.length;
  while (--len && window.scrollY + 97 < section[len].offsetTop) {}
  links.forEach((li) => li.classList.remove("active"));
  links[len].classList.add("active");
  console.log(len);
}
javascript function loops while-loop dom-events
© www.soinside.com 2019 - 2024. All rights reserved.