Javascript examples for Array:slice
Remove trailing elements from array that are equal to zero
<html> <head></head> <body> <script> var arr = [1,2,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; var copy = arr.slice(0);/*from w ww . j a v a 2 s. c o m*/ var number = Number(copy.reverse().join('')).toString().length; arr.length = number; console.log(arr); </script> </body> </html>