You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2. return kata hua ya jo remove kr reh ho vo part karega.
224
+
3. sirf start doge to startIndex se array end tak sab gayab kr dega.
225
+
4. jo items add hoti hai vo startIndex se hi add hona chalu hoti hai.
226
+
5. Remove all elements of array
227
+
```
228
+
arr.splice(0, arr.length);
229
+
```
230
+
213
231
232
+
### slice
233
+
234
+
.slice() method is used to extract a portion of an array (or string) without modifying the original array
214
235
```
215
-
### copyWithin
216
-
copy elements within the array
236
+
slice() // No Slicing, just creates a copy of Array.
237
+
slice(start) // default value of end is last index
238
+
slice(start, end) // start to end-1 index
239
+
217
240
```
218
-
copyWithin(target, start)
219
-
copyWithin(target, start, end)
220
-
copy to targetIndex from startIndex to endIndex
241
+
1. Array kaat ke ney array deta hai.
242
+
2. Existing Array ko kuch nahi hoga.
243
+
3. returns subpart of array
244
+
- Start to End (*end not included*)
245
+
4. Negative index counts back from the end of the array
246
+
-**-1 refers to the last element**
247
+
```
248
+
slice (-1)
249
+
// -1 is startIndex
250
+
// endIndex not given so last index is equal to end Index by default and is baar end index ki value bhi include hogi.
251
+
```
252
+
5. Remember important thing agar end index doge to end index pr jo value hai vo include nahi hogi, aur agar end index nahi doge to startIndex se last index tak ka array return milega.
253
+
6. if start === end then returns empty array
254
+
7. OR in simple words if endIndex <= startIndex then return empty array.
255
+
256
+
257
+
### sort
258
+
sort will sort the array lexically and return the updated array.
259
+
- sort method can take another param that is a comparator
0 commit comments