主要浏览器中仍然存在ECMAScript 3实现差异吗? [英] Are there still ECMAScript 3 implementation differences in major browsers?

查看:105
本文介绍了主要浏览器中仍然存在ECMAScript 3实现差异吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以指出在今天的浏览器中实现ECMAScript第三版的差异吗? (Chrome,Safari,IE8,FF)

Can someone point out the differences in implementation of ECMAScript 3rd edition in today's browsers? (Chrome, Safari, IE8, FF)

使用ECMAScript 3标准(而不是FF和IE对JScript和JavaScript的扩展) p>

Are we safe when using ECMAScript 3 standards (and not the extensions that FF and IE have to JScript and JavaScript)?

推荐答案

当然,有一些实现错误,最严重的是我不得不处理的是JScript,Microsoft实现的标准,例如:

Well, of course there are implementation bugs, the most serious that I've had to deal with are on JScript, the Microsoft implementation of the standard, for example:

FunctionExpressions的标识符应该只能在函数本身的内部范围内访问:

Identifier of FunctionExpressions should be accessible only in the inner scope of the function itself:

(function foo() {
  alert(typeof foo); // "function"
})();

alert(typeof foo);  // should be "undefined", on IE shows "function"

IE版本,它刚刚修复在IE9预览。

The bug is present on all current IE versions, it has just been fixed on IE9 Previews.

实际上更糟糕的是,它创建两个函数对象,例如:

And actually is even worse, it creates two function objects, for example:

var foo = function bar() {};

if (typeof bar != 'undefined') { // the case of IE
  alert(foo === bar); // false!!!
}

另一个众所周知的JScript错误是DontEnum Bug,如果其范围链中的对象包含不可枚举的属性(具有 { DontEnum} 属性),如果属性被遮蔽在其他对象上,它将保持不可枚举,例如:

Another well known JScript bug is the "DontEnum Bug", if an object in its scope chain contains a property that is not enumerable (has the { DontEnum } attribute), if the property is shadowed on other object, it will stay as non-enumerable, for example:

var dontEnumBug = {toString:'foo'}.propertyIsEnumerable('toString');

它将在IE上评估为 false 这会导致使用 for-in 语句时出现问题,因为将不会访问这些属性。

It will evaluate to false on IE, this causes problems when using the for-in statement, because the properties will not be visited.

推荐文章:

  • JScript deviations from ES3pdf

这篇关于主要浏览器中仍然存在ECMAScript 3实现差异吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆