Исходя из того, что вы мне сказали, я думаю, что это решит вашу проблему.Он превращает $hubbe.pallet
в массив, поэтому остальная часть вашего кода также работает:
$hubbe.pallet = []; //declares the array
for (var i = 0; i < $hubbe.colors.length; i++) {
var temp = document.createElement('DIV'); //create temp variable to work with
temp.setAttribute('class', 'pallet');
temp.style.backgroundColor = $hubbe.colors[i];
Object.assign(temp.style, {
width: '40px',
height: '40px',
border: '2px solid #2c3e50',
margin: '20px 0 0 5px',
disaply: 'block',
cursor: 'pointer',
});
$hubbe.toolbarLeft.appendChild(temp);
$hubbe.pallet[i] = temp; //adds the object to the array
}