javascript truncate array

JavaScript
array.slice(0, 4);
Source

Also in JavaScript: