What is meaning of defaults: function($super)
and domain: function($super)
in javascript?. The following code is taken from openstack-horizon. They are using very high level of javascript concept but I know basic of javascript.
Rickshaw.Graph.Renderer.StaticAxes = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Line, {
name: 'StaticAxes',
defaults: function($super) {
alert("13 => This is repeated many time. Rickshaw.Graph.Renderer.StaticAxes");
return Rickshaw.extend($super(), {
xMin: undefined,
xMax: undefined,
yMin: undefined,
yMax: undefined
});
},
domain: function($super) {
//alert("HJ");
var ret = $super();
var xMin, xMax;
// If y axis wants to have static range, not based on data
if (this.yMin !== undefined && this.yMax !== undefined) {
ret.y = [this.yMin, this.yMax];
}
// If x axis wants to have static range, not based on data
if (this.xMin !== undefined && this.xMax !== undefined) {
xMin = d3.time.format.utc('%Y-%m-%dT%H:%M:%S').parse(this.xMin);
xMin = xMin.getTime() / 1000;
xMax = d3.time.format.utc('%Y-%m-%dT%H:%M:%S').parse(this.xMax);
xMax = xMax.getTime() / 1000;
ret.x = [xMin, xMax];
}
return ret;
}
});
Consider this code.
var objectLiteral = {
variable: "I'm a string",
fun: function(param) {
console.log("I'm a function.");
console.log("Here's the param: ", param);
}
}
console.log(objectLiteral);
objectLiteral.fun();
fun
and variable
are fields of the object literal.
function()
syntax is used to declare a function, which get assigned to fun
.