gpt4 book ai didi

javascript - javascript中的域和默认函数是什么意思?

转载 作者:行者123 更新时间:2023-12-03 09:30:18 25 4
gpt4 key购买 nike

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();

funvariable 是对象字面量的字段。
function() 语法用于声明一个函数,该函数被分配给 fun

关于javascript - javascript中的域和默认函数是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31530536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com