0
我有这样的功能:Javascript超时 - 函数中的值如何记住?
//We will store any failed subscriptions and retry them until the succeed (if ever)
addFailedSubscription: function(streamId) {
failedSubscriptions[streamId] = true;
$timeout(function() {
failedSubscriptions[streamId] = null;
}, 5000);
}
这安全吗?在函数返回后,streamId对超时函数是否可用?它是否有效地创建了这个函数的闭包?
感谢
是的,这是一个封闭。 – Pointy