- 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

15th Dec 2020, 3:05 PM
born2code
born2code - avatar
1 Réponse
+ 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 ).
15th Dec 2020, 4:00 PM
Ipang