DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
    • can-construct
    • can-control
    • can-event
    • can-event/async/async
    • can-event/batch/batch
    • can-observation
    • can-simple-map
    • can-util
    • can-view-callbacks
    • can-view-live
    • can-view-model
    • can-view-nodelist
    • can-view-parser
    • can-view-scope
      • types
        • Meta
      • static
        • Options
      • prototype
        • add
        • compute
        • get
        • peek
        • set
    • can-view-target
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Infrastructure
  • /
  • can-view-scope
  • /
  • peek
  • / On this page
    • peek

      function

      Read a value from the scope without being observable.

      • source

      scope.peek(key [, options])

      Works just like get, but prevents any calls to add.

      Walks up the scope to find a value at key. Stops at the first context where key has a value.

      scope.peek("first.name");
      

      Parameters

      1. key {key}:

        A dot seperated path. Use "." if you have a property name that includes a dot.

      Returns

      {*}:

      The found value or undefined if no value is found.

      Use

      scope.peek(key) looks up a value in the current scope's context, if a value is not found, parent scope's context will be explored.

      var list = [{name: "Justin"},{name: "Brian"}],
          justin = list[0];
      
      var curScope = new Scope(list).add(justin);
      
      curScope.peek("name"); //-> "Justin"
      curScope.peek("length"); //-> 2
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.