<style>#slider{width: 100px; height: 100px;}</style>
<body>
<div id="slider"></div>
<script>
window.onload = function () {
var obj = {
__colors: [],
__position: 0,
get color() {
if (this.__position == this.__colors.length) this.__position = 0;
return this.__colors[this.__position++];
},
set color(arg) {
this.__colors = arg;
}
};
obj.color = ['red', 'green', 'black', 'yellow', 'fuchsia'];
setInterval(function () {
document.getElementById('slider').style.backgroundColor = obj.color;
}, 1000);
};
</script>
</body>
вариант