是否有一个库可以在所有浏览器中创建 JavaScript 1.8 兼容性?

发布于 2025-01-05 21:57:47 字数 150 浏览 0 评论 0原文

浏览 Mozilla JavaScript 网站,我发现 JavaScript 1.8 有很多很棒的功能。在大多数情况下,如果该功能未在用户的浏览器上实现,您可以添加代码来扩展基本类型的原型。是否有一个库可以用来添加所有这些功能,从而在您的代码中自由使用 JavaScript 1.8?

Looking through the Mozilla JavaScript site, I see that JavaScript 1.8 has a lot of great functions. In most cases it has code you can add to extend prototypes of the basic types in the case that the function is not implemented on the user's browser. Is there a library that you can use to add all those functions and therefore use JavaScript 1.8 freely in your code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情泪▽动烟 2025-01-12 21:57:47

您可能正在寻找垫片。
查看 es5-shim:https://github.com/kriskowal/es5-shim/

Modernizr 有一个非常详尽的替代 polyfill 或 shim 列表(wiki)(根据您的需要查看 ECMAScript 5):
https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross -browser-Polyfills

此外,并非所有功能都可以由 shim 或 polyfill 提供。您可以针对您想要但未提供的功能发起一个问题(请记住首先搜索并阅读自述文件),开发人员可能会告诉您是否不可能。

You are probably looking for a shim.
Check out the es5-shim: https://github.com/kriskowal/es5-shim/

Modernizr has a pretty exhaustive list (wiki) of alternative polyfills or shims (look under ECMAScript 5 for your needs):
https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills

Also, not all features can be provided by shims or polyfills. You could start an issue (remember to search and read the README first) for a feature that you want but isn't provided and the developer might tell you if it's not possible.

熊抱啵儿 2025-01-12 21:57:47

由于这个版本有很多语法差异(Rob W 提到过),所以只有两种方法可以做到这一点。

  • 有人必须用 JavaScript 编写 JS 解释器,这会非常慢。
  • 编写一个服务器端编译器,将 JavaScript 1.8 转换为 EcmaScript。

不,那里没有人。

Since this version has lots of syntax differences (mentioned by Rob W), there are only two way this can be done

  • Somebody would have to write a JS interpreter in JavaScript, which would be good awful slow.
  • Write a server side compiler that turns JavaScript 1.8 into EcmaScript.

No, there isn't one out there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文