Backbone.JS Set()

The Backbone.JS Set() collection method is used to update a collection with a set of items in a model.

Syntax:

Backbone.Collection.Set ( models, options )   

Parameters: models: This parameter is used to specify the models to be set in the collection. options: This parameter is used to specify the parameters like id, name, etc.

Example:

  

  
Example  
  
  
  
  
  
  
  
  

Output:

[{"number":2},{"number":5}]

Explanation: In the above example, the Set() method update the ‘num1’ model by passing the value in the collection.

Please follow and like us:
Content Protection by DMCA.com