how to truncate an array in javascript code example Example: javascript truncate array array.slice(0, 4);