Backbone.js escape Model
In this article, we will see the Backbone.js escape() model. The Backbone.js escape() model is used to return or get the HTML escaped version of an attribute in the given model. It is similar to a get() model. While interpolating the data from the model to the HTML, use the escape that will help to retrieve the attributes, in order to prevent it from XSS attack.
Parameters: It accepts an only a single parameter:
- attribute: It specifies the attribute in a model to be returned.
Example 1: The following example demonstrates the book model returning its attributes (string data) using the JSON.stringify() method.
Example 2: The following example demonstrates the escape() model.
bookid: 23 price: 678 book_name: css