- 1
Can anyone explain me how the output came??
// JAVASCRIPT ARRAY METHOD - slice() var arr=["AngularJS","Node.js","JQuery","Bootstrap"]  var result=arr.slice(-4,-1); Output: AngularJS , Node.js , JQuery
1 Answer
+ 1
Numbers in parentheses are negative index
INDEX 0 (-4) 1 (-3) 2 (-2) 3 (-1)
VALUE AngularJS NodeJS jQuery Bootstrap
arr.slice( -4, -1 ) means slice array <arr> from index -4 (or index 0) up to index -1 (or index 3 exclusively ).