<script>
function fun(arr) {
let time = performance.now();
Object.defineProperty(window, "a", {
get: function() {
let i = Math.trunc((performance.now() - time)/1000) % arr.length;
return arr[i]
}
});
return window.a
}
fun([1, 2, 3, 4, 5]);
window.setInterval(_ => document.body.append(`${a} `) , 1001)
</script>