VOOZH about

URL: https://www.geeksforgeeks.org/javascript/backbone-js-unshift-collection/

⇱ Backbone.js unshift Collection - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Backbone.js unshift Collection

Last Updated : 12 Dec, 2022

The Backbone.js unshift Collection is used to add model at the beginning of a Collection. It takes model as the first parameter and options as the second parameter. In this article, we will discuss the Backbone.js unshift Collection. 

Syntax: 

collection. unshift( model, options );

Parameters: 

  • model: This parameter is used to specify the model's instance which is going to add to the collection.
  • options: This is an optional parameter regarding the model which is being added to the collection.

Example 1: In this example, we will illustrate The Backbone.js unshift collection. In this example, we will add 2 models using unshift in the collection.

Output:

👁 Image
Backbone.js unshift collection

Example 2: In this example, we will again add two models at beginning of the collection.

Output:

👁 Image
Backbone.js unshift collection

Reference: https://backbonejs.org/#Collection-unshift

Comment