Slice does not modify the original array, but instead returns a shallow copy of elements from the original array.

This function is valid in v2.0.0 to v2.23.0. This function has been downloaded 48 times.


{Array|Arguments|Object} array
Array or array-like object to shallow copy.
{number=} begin Optional
Zero-based index at which to begin extraction. A negative index can be used, indicating an offset from the end of the sequence. slice(array,-2) extracts the last two elements in the sequence. If begin is undefined, slice begins from index 0.
{number=} end Optional, Default:array.length
Zero-based index before which to end extraction. slice extracts up to but not including end. For example, slice(array,1,4) extracts the second element through the fourth element (elements indexed 1, 2, and 3). A negative index can be used, indicating an offset from the end of the sequence. slice(array,2,-1) extracts the third element through the second-to-last element in the sequence. If end is omitted, slice extracts through the end of the sequence (array.length). If end is greater than the length of the sequence, slice extracts through the end of the sequence (array.length).


A new array containing the extracted elements.

Required Function

This function directly requires the following function which is included automatically:

  • alias()
    Binds a context to a given function within that context.

Requiring Functions

This function is directly required by the following functions:

  • attempt()
    Attempts to call a function if one exists at the given path starting at the given root object.
  • bind()
    Creates a function that when called will call fn with this referring to objThis and any values in opt_args be passed as the first arguments to fn.
  • call()
    Calls a function whether it be a global prototype function or a YourJS function or a custom bindable.
  • calls()
    Makes multiple calls using the YourJS call() function.
  • cap()
    Puts a cap (limit) on the amount of arguments that a function can receive.
  • capProto()
    Creates a wrapper function for a prototype function that can be capped (limited in the amount of arguments it can receive).
  • chain()
    Creates a chained version of a value.
  • construct()
    Constructs an object with an arbitrary number of arguments passed via an array (or an array-like object).
  • curry()
    Creates a wrapper function that will only execute the given function once the number of arguments passed is at least a given amount. If the wrapper is called with too few arguments, those arguments will be recursively stored within a new wrapper function.
  • deburr()
    Converts supplementary latin letters into basic latin letters, removing the diacritical marks. In other words this normalizes a string.
  • defer()
    Defers calling a function until the current call stack is done. Similar to using the global setTimeout function.
  • delay()
    Calls a function after a given amount of time. This is very similar to the global setTimeout function.
  • diffArrays()
    Creates a new array which is the difference of the two given arrays.
  • doEvery()
    Execute a function every so often. Similar to setTimeout.
  • everyWhere()
    Determines whether a specific test passes for all of the items in an array.
  • exec()
    Calls a function and returns it so it can be called again.
  • findWhere()
    Finds the first item in an array which matches the specified criteria.
  • is()
    Tests to see if two or more values are exactly the same. This is similar to === but will also indicate that NaN is NaN and will indicate that -0 is not 0.
  • isKind()
    Checks to see if a value is of a specific kind.
  • isKindFor()
    Creates a partial isKind() function.
  • isRegExpMatch()
    Determine whether or not a RegExp matches an entire string (or the start of a string).
  • isTypeFor()
    Creates a partial isType() function.
  • partial()
    Creates a copy of a function with the left-most arguments preset.
  • partialAny()
    Creates a partial function where the arguments in any position can be set. Also allows for setting the value of this.
  • rearg()
    Creates a new wrapper function that will call the original the arguments in a different order.
  • restParam()
    Creates a wrapper function that if called with more arguments than specified, those arguments will be passed in as an array in the final argument.
  • reverse()
    Takes an array (or an array-like object) or a string, copies it, and returns the copy in reverse order.
  • sample()
    Takes an array and returns a new array with some or all of the original values not usually in the same order.
  • splice()
    Duplicates an array or a string and adds and/or removes one or more values from it. NOTE: This is different from the traditional splice function because it doesn't modify the array, but rather it returns a modified duplicate.
  • spread()
    Calls a function while flattening first-level array-like arguments so as the spread those individual values and use them as individual arguments.
  • spreadNew()
    Passes an array as the arguments to a construct thusly allowing a variable number of arguments to be passed to the constructor.
  • toArray()
    Turns anything into an array.
  • toggle()
    Toggles values in an array, adding the values that are missing from the array and removing those that are there.
  • unbind()
    Unbinds a value from a function (such as a prototypal function) and creates a wrapper function that when called will use the 1st argument as the bound value.
  • uniquify()
    Creates a new version of an array with all of the duplicate values removed.
  • wait()
    Creates a waiter function which takes orders and serves orders in a way and calls a ready function when all orders have been served.