为什么这样做:
a = []
a.push(['test']);
(function() {alert('poop')})()
Run Code Online (Sandbox Code Playgroud)
但这给出了错误"数字不是函数":
a = []
a.push(['test'])
(function() {alert('poop')})()
Run Code Online (Sandbox Code Playgroud)
唯一的区别是第2行末尾的分号.我已经写了很长时间的Javascript.我知道自动分号插入,但我无法弄清楚会导致此错误的原因.
我正在尝试绘制D3.js中客户的平均寿命.我已经绘制了数据,但我无法弄清楚如何绘制显示中位数寿命的参考线.我想要在y轴的50%值处与我的数据相交的垂直和水平参考线.
这是我目前的情况:

垂直参考线需要与水平参考线在相同位置的数据相交.
这是我的代码:
d3.json('data.json', function(billingData) {
var paying = billingData.paying;
var w = 800;
var h = 600;
var secondsInInterval = 604800000; // Seconds in a week
var padding = 50;
var age = function(beginDate, secondsInInterval) {
// Calculate how old a subscription is given it's begin date
var diff = new Date() - new Date(beginDate);
return Math.floor(diff / secondsInInterval);
}
var maxAge = d3.max(paying, function(d) { return age(d.subscription.activated_at, secondsInInterval); });
var breakdown = new Array(maxAge);
$.each(paying, function(i,d) { …Run Code Online (Sandbox Code Playgroud) 如果我编写如下所示的 Gateway 和 VirtualService 条目,主机属性匹配什么标准来确定是否应将传入请求路由到服务?它是 HTTP 请求中的“主机”标头,还是其他什么?
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: default-gateway
namespace: web
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- example.com
port:
name: www
number: 80
protocol: HTTP
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: web
namespace: web
spec:
gateways:
- default-gateway
hosts:
- example.com
http:
- route:
- destination:
host: webserver # assume this is the name of the Service for our deployed container
---
# Assume a Service and Deployment exist for the above …Run Code Online (Sandbox Code Playgroud)