![]() ![]() This parameter is the starting index from which array items will be copied and the copied items will include the item at this index. The first parameter is the begin parameter. This means that a parameter value of -3 would actually result in the value of that parameter being 3 less than the length of the array ( Array.length + -3). If either of these parameters has a negative value, they will be counted from the end of the array instead of from the beginning. The slice() function takes up to two parameters, both of which are zero-based indexes and both of which are optional. No further precautions need to be taken before beginning the operation in order to maintain a copy of the original array. As this function produces a completely new array, the original array is left completely unaltered once the function has completed the operation. The slice() function provides the ability to shallow copy a portion of the items in an array into a completely new array and return that new array upon function completion. One of those useful functions that will be explored in this article is the slice() function. ![]() These functions offer a number of advantages, the most noteworthy of which is the fact that, while at one time in the past developers had to implement their own complex logic to perform various array operations, now the need for such homegrown implementations has been eliminated by all of these new functions. There have been many useful functions that have been added to the Javascript Array global object over the last few years that offer developers a wide variety of options when they are writing code that works with arrays.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |