Skip to content

Instantly share code, notes, and snippets.

@harboe
harboe / knockout-observableArrayMap.js
Last active December 18, 2015 03:58
Knockout ObservableArray Map. Snippet from: Ryan Niemeyer - Getting the Most Out of Knockout.js @ http://vimeo.com/51103092
(function (undefined) {
//
// simple map function to extend the observableArray.
ko.observableArray.fn.map = function (data, Constructor) {
var mapped = ko.utils.arrayMap(data, function (item) {
return new Constructor(item);
});
this(mapped);