peek
Read a value from the scope without being observable.
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
- key
{key}
:A dot-separated 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"}];
var justin = list[0];
var curScope = new Scope(list).add(justin);
curScope.peek("name"); //-> "Justin"
curScope.peek("length"); //-> 2