dojo.getObject returns the property of an object from a dot-separated string such as “A.B.C”
The simplest way to use dojo.getObject is to pass a dot-separated string as shown below:
// Dojo 1.7+ (AMD)
// define an object (outside function, in global scope to demonstrate)
var foo = {
bar: "some value"
require(["dojo/_base/lang"], function(lang){
// get the "foo.bar" property
lang.getObject("foo.bar"); // returns "some value"
// Dojo < 1.7
// define an object
var foo = {
bar: "some value"
// get the "foo.bar" property
dojo.getObject("foo.bar"); // returns "some value"
dojo.getObject also takes an optional boolean parameter which, if true, will create the property if it does not exist. Any other properties along the path will also be created along the way. The default value is false.
// Dojo 1.7+ (AMD)
// define an object (outside function, in global scope to demonstrate)
var foo = {
bar: "some value"
require(["dojo/_base/lang"], function(lang){
// get the "foo.baz" property, create it if it doesn't exist
lang.getObject("foo.baz", true); // returns foo.baz - an empty object {}
foo == {
bar: "some value",
baz: {}
// Dojo < 1.7
// define an object
var foo = {
bar: "some value"
// get the "foo.baz" property, create it if it doesn't exist
dojo.getObject("foo.baz", true); // returns foo.baz - an empty object {}
foo == {
bar: "some value",
baz: {}
You can also pass an object as the third parameter. This will define the context in which to search for the property. By default, the context is dojo.global.
// Dojo 1.7+ (AMD)
require(["dojo/_base/lang"], function(lang){
// define an object
var foo = {
bar: "some value"
// get the "bar" property of the foo object
lang.getObject("bar", false, foo); // returns "some value"
// Dojo < 1.7
// define an object
var foo = {
bar: "some value"
// get the "bar" property of the foo object
dojo.getObject("bar", false, foo); // returns "some value"
dojo.setObject
dojo.exists
reserved. The OpenJS Foundation has registered trademarks and uses
trademarks. For a list of trademarks of the OpenJS Foundation, please see
our Trademark Policy and Trademark List. Node.js is a trademark of Joyent, Inc. and
is used with its permission. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™
or registered® trademarks of their respective holders. Use of them does not imply any affiliation with
or endorsement by them.
The OpenJS Foundation | Terms of
Use | Privacy Policy | OpenJS Foundation Bylaws | Trademark Policy | Trademark List | Cookie Policy | Dojo
Toolkit License Information