JavaScript: work with array