O'Reilly logo

Getting Started with Knockout.js for .NET Developers by Andrey Akinshin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Custom functions

Knockout.js allows you to write your own custom functions to extend the capabilities of a standard Knockout.js object. The following objects from the Knockout.js hierarchy can be extended:

  • ko.subscribable (root object)
  • ko.computed (inherited from ko.subscribable)
  • ko.observable (inherited from ko.subscribable)
  • ko.observableArray (inherited from ko.observable)

If you write a custom function for an object, the inheritors of the object will also have the written function. For example, you can use a custom function of ko.observable with ko.observableArray.

An example with array filtering

Let's learn how to write a custom function with the following example. We will write the filterByProperty function for ko.observableArray. This function ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required