I am working with jquery float, and stumbled upon a function I can't figure out (console logs are mine):
function getOrCreateAxis(axes, number) {
console.log(" ");
console.log("getOrCreateAxis starting vars:");
console.log("Axes:");
console.log(axes);
console.log("Axes -1:");
console.log(axes[number-1]);
console.log("Xaxes:");
console.log(xaxes);
console.log("options are:");
console.log(options);
if (!axes[number - 1])
axes[number - 1] = {
n: number, // save the number for future reference
direction: axes == xaxes ? "x" : "y",
options: $.extend(true, {}, axes == xaxes ? options.xaxis : options.yaxis)
};
console.log("We're done in getOrCreateAxis, axes are:" + (axes == xaxes ? "x" : "y"));
console.log(axes);
console.log(" ");
return axes[number - 1];
}
As I understand it, it receives an empty array, checks if certain index exist, and if not, it creates new object at that index with properties "n", "direction" and "options" (merged in from another array).
What I can't figure out is where all the additional properties other than three above come from, when you console.log the axes array:
As far as I understand it, there's some kind of constructor automatically kicking in populating the object with additional properties but I can't figure out where it comes from or how it is triggered. Full Jquery Flot code available here, function I am struggling with is on the line 980.
The question might be bit abstract, but I feel lost here as I don't even know what I am looking for, technically. What is creating additional properties, and where can I read more about it?