Version: 1.1, Last updated: 12/24/2009
jQuery getObject: get. | Version: 1.1, Last updated: 12/24/2009 |
License | Copyright © 2009 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses. |
Support and Testing | Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself). |
Release History | |
Note for non-jQuery users | jQuery isn’t actually required for this plugin, because nothing internal uses any jQuery methods or properties. |
Note for Dojo users | The setObject, getObject, and exists methods are similar to their Dojo counterparts, with the exception that exists returns true or false based on whether or not a property is defined, not whether it is truthy. |
Functions | |
jQuery. | Get a property of an object via dot-delimited name string, and optionally create the property and any ancestor properties that do not already exist. |
jQuery. | Set a property of an object via dot-delimited name string, creating any ancestor properties that do not already exist. |
jQuery. | Using dot-delimited name string, return whether a property of an object exists. |
Copyright © 2009 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses. http://benalman.com/about/license/
Inspired by Dojo, which is Copyright © 2005-2009, The Dojo Foundation.
Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
jQuery Versions | none, 1.3.2, 1.4a2 |
Browsers Tested | Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome, Opera 9.6-10. |
Unit Tests | http://benalman.com |
jQuery isn’t actually required for this plugin, because nothing internal uses any jQuery methods or properties. jQuery is just used as a namespace under which these methods can exist.
Since jQuery isn’t actually required for this plugin, if jQuery doesn’t exist when this plugin is loaded, the methods described below will be created in the `Cowboy` namespace. Usage will be exactly the same, but instead of $.method() or jQuery.method(), you’ll need to use Cowboy.method().
Get a property of an object via dot-delimited name string, and optionally create the property and any ancestor properties that do not already exist.
jQuery.getObject( name [, create ] [, context ] );
name | (String) Dot-delimited string representing a property name, for example: ‘document’, ‘location.href’, ‘window.open’ or ‘foo.bar.baz’. |
create | (Boolean) Create final and intermediate properties if they don’t exist. Defaults to false. |
context | (Object) Optional context in which to evaluate name. Defaults to window if omitted. |
(Object) An object reference or value on success, otherwise undefined.
Set a property of an object via dot-delimited name string, creating any ancestor properties that do not already exist.
jQuery.setObject( name, value, [ context ] );
name | (String) Dot-delimited string representing a property name, for example: ‘document’, ‘location.href’, ‘window.open’ or ‘foo.bar.baz’. |
value | (Anything) Any valid JavaScript expression. |
context | (Object) Optional context in which to evaluate name. Defaults to window if omitted. |
(Anything) The value if set successfully, otherwise undefined.
Using dot-delimited name string, return whether a property of an object exists.
jQuery.exists( name [, context ] );
name | (String) Dot-delimited string representing a property name, for example: ‘document’, ‘location.href’, ‘window.open’ or ‘foo.bar.baz’. |
context | (Object) Optional context in which to evaluate name. Defaults to window if omitted. |
(Boolean) Whether or not the property exists.