title: How to access knockout viewmodel from javascript
body: <p>I am trying to understand how to manage the scope in my Javascript code.  Once I create a viewmodel, how do I access it from the rest of my javascript? (last line in this code generates a 'not defined' error  </p>
  
  <p>NOTE: I have found several posts on the differences between function/var for ko, but none have said there is a scoping advantage with using a var... so I have tried both methods.</p>
  
  <pre><code>//function AppViewModel() {
  //    this.gridSize = ko.observable("30");
  //    this.canvasWidth = ko.observable("600");
  //    this.canvasHeight = ko.observable("600");
  //    this.displayCoords = "Axial";
  //    this.pixel="0";
  //    this.hex="0";
  //}
  //ko.applyBindings(new AppViewModel());
  
  var AppViewModel = {
      gridSize: ko.observable("30"),
      canvasWidth: ko.observable("600"),
      canvasHeight: ko.observable("600"),
      displayCoords: "Axial",
      pixel:"0",
      hex:"0"
  };
  ko.applyBindings(AppViewModel );
  
  var test = AppViewModel.gridSize;
  </code></pre>