So I was reading the javascript file of a website and I saw a variable wrapped in square brackets, can someone explain to me what and why that is? I do understand the whole code and what It does except for that part. The variable I'm talking about is 'entry'.
const fadeIn = function (entries, observer) {
const [entry] = entries;
if (!entry.isIntersecting) return;
entry.target.classList.add("scroll-reveal");
observer.unobserve(entry.target);
};
const observer = new IntersectionObserver(fadeIn, {
root: null,
threshold: 0.5,
});
reveals.forEach((curr) => {
observer.observe(curr);
});