Home/knockout/What is Knockout.js and how is it differ from jQuery?

What is Knockout.js and how is it differ from jQuery?

What is Knockout JS?

Knockout is a JavaScript library that helps you to create rich, responsive UI and with clean data model. In other word, It is a javascript library that allows us to bind html elements against any data model. It provides a simple two-way data binding mechanism between our data model and UI.

Why Knockout?

The User interface(UI) data section will update dynamically when any changes had updated by user’s action or any external data update the Knockout is the best solution for simple to handle it. Its provide a simple mechanism to handle out data model and UI. For example if any changes made on data model are automatically it will reflect in the DOM(User Interface) and if any changes to on the DOM will automatically reflected to the data model.

With Simple Real time example

Let we discuss about with simple shopping cart Interface. If user add an item in the shopping cart, then it need to have to add the items from the data model and add the associated html element to the shopping cart. Finally the total price need to update in the UI. Consider the same scenario for the delete operation, same need to be update in all the scenario. So if we are not using knockout for doing this, then we need to write event handlers and listeners for dependent.

Let we conclude, the knockout will track all dependencies between the HTML and their underlying data and update dynamically(automatically) when update has made by user or from the back-end (update made by system side).

How is Knockout differ?

We all loves jQuery for its excellent way to manipulate elements and event handlers in a web page. But KO is solves a different problem. It is not a replacement of jQuery or other framework. It not target to provide animation, AJAX functionality or generic event handling. It is focused only on designing salable and data-driven interface.

Leave a Reply