【发布时间】:2015-05-27 13:03:28
【问题描述】:
为什么会这样:
setTimeout(function(){
var myObj = {
'hello':'world',
'more':'things'
};
_.each(myObj, function(value, key){
console.log(key, value);
});
// why doesn't this output anything?
_.each(performance.timing, function(value, key){
console.log(key, value);
});
// just to make sure we can
console.log(performance.timing);
},500);
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
输出这个:
> hello world
> more things
> PerformanceTiming {}
我希望对象的键和值得到与myobj 相同的输出。
下划线:http://jsfiddle.net/a43vb7gd/1/
lodash:http://jsfiddle.net/mkxncwax/1/
在 Ubuntu 14.04.2 LTS 上的 Chrome 43.0.2357.81 和 Firefox 38.0 上重现。
【问题讨论】:
-
在 Chrome 上运行良好
-
您在哪个浏览器中遇到问题?
-
刚刚编辑了您的代码以使用 snipplet,我看到了您在 OSX 上使用 chrome 看到的内容
-
@mshaaban 它在 Ubuntu 14.04 上的 Chrome 和 Firefox 上为我重现。已添加到问题中。
标签: javascript performancecounter