the code that implements the paging algorithm for the picture above is a little confusing.
1. Isn"t the page declared by const a constant? Doesn"t page change every time forEach iterates through it? But why did not report wrong, is not my understanding wrong, or my knowledge point blind spot?
2. The overall algorithm is a bit confusing. Please give us some advice. Thank you
Code:
pages () {
const=[]
this.iconList.forEach((item,index) => {
const page =Math.floor(index/8)
if(!pages[page]){
pages[page]=[]
}
pages[page].push(item)
})
return pages
}