[英]What is meaning of domain and default function in javascript?
javascript中的defaults: function($super)
和domain: function($super)
是什么意思? 以下代码来自openstack-horizon 。 他们使用了非常高级的javascript概念,但是我知道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;
}
});
考虑下面的代码。
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
和variable
是对象文字的字段。
function()
语法用于声明一个函数,该函数被分配给fun
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.