Backbone.JS HasChanged()

The Backbone.JS HasChanged() model is used to get the TRUE value if the attributes have changed since the last set of the model attributes.

Syntax:

Model.HasChanged (attributes)   

Parameters:
attributes: This parameter is used to specify the properties of a model.

Example:

<!DOCTYPE html>  
<html>
<head>  
<title>Example</title>  
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js" type="text/javascript"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js" type="text/javascript"></script>  
<script type="text/javascript">  
var X = new Backbone.Model({  
msg: "HELLO WORLD.",  
});  
document.write('MESSAGE has changed = ' + X.hasChanged());  
X.set('msg', 'Welcome', {silent: true});  
document.write('<br>MESSAGE has changed = ' + X.hasChanged());  
</script>  
</head>  
</html>

Output:

MESSAGE has changed = false
MESSAGE has changed = true

Explanation:
In the above example, message has changed after the set.

Please Share