Is Array.slice negative negative safe?

I remember how many years ago I recalled that passing negative numbers as a second argument to some functions with this syntax ( slice , substr , etc.) was supported only in some browsers, but I can not find the link.

It’s just interesting to know if anyone knows that ary.slice(0, -1) safe for all browsers.

+5
source share
1 answer

Using a negative number for the start or end value (or both) is safe and will select from the end of the array. It is supported through IE, FF, Chrome, Safari and Opera.

+2
source

Source: https://habr.com/ru/post/1263119/


All Articles