Backbone.JS ChangedAttributes()

The Backbone.JS ChangedAttributes() model is used to get the model’s attributes that have changed since the last set and becomes false if there are no attributes.

Syntax:

Model.ChangedAttributes (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>  
</head>  
<body>  
<script type="text/javascript">  
var X = new Backbone.Model({ 
sub: "Example.",
msg: "HELLO WORLD.",  
end: "Thanks."
});  
X.on('change', function() {  
document.write("Changed attributes: ");  
document.write(JSON.stringify(X.changedAttributes()));  
});  
X.set({  
sub: "Just another Example.",
msg : "Hello World."
});  
</script>  
</body>  
</html>

Output:

Changed attributes: {"sub":"Just another Example.","msg":"Hello World."}

Explanation:
In the above example, the attributes ‘msg’ and ‘sub’ of a model X has changed.

Please Share