Backbone.JS Slice()

The Backbone.JS Slice() collection method displays the shallow copy of the elements from the collection model.

Syntax:

Collection.Slice ( begin, end )   

Parameters:
begin: This parameter is used to specify the beginning of the element.
end: This parameter is used to specify the end of the element.

Example:

  

  
Example  
  
  
  
  
  
  
  


  

Output:

Number of rhyming names:3
["Sim","Tim","Vim"]

Explanation:
In the above example, the Slice() method begins the element extraction at index 2 and ends the extraction of elements at index 5.