DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • get
  • / On this page
    • get

      function
      • source

      get(obj, path)

      Parameters

      1. obj {Object}:

        the object to use as the root for property based navigation

      2. path {String}:

        a String of dot-separated keys, representing a path of properties

      Returns

      {*}:

      the value at the property path

      A path is a dot-delimited sequence of zero or more property names, such that "foo.bar" means "the property 'bar' of the object at the property 'foo' of the root." An empty path returns the object passed.

      var get = require("can-util/js/get/get");
      console.log(get({a: {b: {c: "foo"}}}, "a.b.c")); // -> "foo"
      console.log(get({a: {}}, "a.b.c")); // -> undefined
      console.log(get([{a: {}}, {a: {b: "bar"}}], "a.b")); // -> "bar"
      

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