Skip to content

Instantly share code, notes, and snippets.

@carolynvs
Last active October 13, 2015 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carolynvs/4264028 to your computer and use it in GitHub Desktop.
Save carolynvs/4264028 to your computer and use it in GitHub Desktop.
Initializing Knockout.js Observables
var valueType = true;
var oValueType = new ko.observable(valueType);
oValueType(false);
// valueType is unchanged
var array = [1, 2, 3];
var oArray = new ko.observableArray(array);
oArray.remove(1);
// array is modified, now equals [2, 3]
var date = new Date();
var oDate = new ko.observable(date);
oDate().clearTime();
// date is modified and the time portion has been removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment