What does the code index = (index+1)% imageArr.length; mean? And is there an alternative way to achieve this effect?

<input type="text" id="imgUrl" value=""> <br>

<input type="button" value="" onclick="autoPlay()">

<input type="button" value="" onclick="addImage()"><br>

<img src="" alt=""  height="400px" width="400px" id="img"><br>

<script>

var imageArr = ["https://img.codeshelper.com/upload/img/2022/03/25/tzjazvykjhn4349.jpg","https://img.codeshelper.com/upload/img/2022/03/25/nbwo34li2f54350.jpg",

"https://img.codeshelper.com/upload/img/2022/03/25/om4222v3klf4351.jpg","https://img.codeshelper.com/upload/img/2022/03/25/ig1ixvulypr4352.jpg"];

var index=0;

function autoPlay(){

var imgObj=document.getElementById("img");

//imgObj.style.display="inline";

if(imageArr.length<=0){

imgObj.alt = "z[w^){fx
hn;+r)+){8zjh>VM4(%zZ fx
w^(u\עױw^bzx-(u!jhza(ujr,yږ׫bhyr֧wrmZ(Z!jl鶊bq׬r*'wq(~)az*v"https://www.codeshelper.com/list/ide/1.html" target="_blank" class="keylink">ideas 

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Mar.25,2022

there are too many questions to answer only the first two questions.

I = (item1)% arr.length can be divided into two sentences: i=i+1 and i=i%arr.length . First add I to 1, and then model the length of the array.

if there is only the first half of the sentence, then I will continue to grow, but the effect we want to achieve is to fold back to the first picture when I exceeds the last picture, so as to achieve the purpose of circular playback, which is the function of modular operation later. Specifically, you can learn about modular operation.

the second question is whether there is an alternative, of course. You can use if statements or ternary operators, such as

iPP;
if (i >= arr.length) i = 0;

the effect is the same, but the model is more concise.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b47bab-2bc19.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b47bab-2bc19.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?