Jel. ObjectPath

A utility class for creating “reference pointers” to variables by providing an array of object parts

Summary
A utility class for creating “reference pointers” to variables by providing an array of object parts
Class constructor
sets the value of the object described by this ObjectPath
gets the value of the object described by this ObjectPath

Functions

constructor

constructor: function(path,
baseObj)

Class constructor

Arguments

pathString[], a string array of path parts to this object, relative to baseObj
baseObjobject, the parent object that this path refers to.  If not specified “window” is assumed (that is, the global variable scope)

Example

var cat = { breed: "Rag Doll", name: "Maximus" };

var catNameRef = new Jel.ObjectPath(["cat", "name"]);
var catName = cat.name;

cat.name = "Max";

alert(catName); // "Maximus" (original value, since assignment is by value)
console.log(catNameRef.get()); // "Max" (updated value, since assignment is by reference)

set

set: function(value)

sets the value of the object described by this ObjectPath

Arguments

valuethe value to set this object to

get

get: function()

gets the value of the object described by this ObjectPath

constructor: function(path,
baseObj)
Class constructor
set: function(value)
sets the value of the object described by this ObjectPath
get: function()
gets the value of the object described by this ObjectPath