javascript Shim vs. Sham:有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27508833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 07:34:18  来源:igfitidea点击:

Shim vs. Sham: What is the difference?

javascriptecmascript-5ecmascript-6polyfills

提问by garbanzio

What is the difference between a shim an a sham?

shim 和 sham 有什么区别?

Is it enough to include es5-shim.min.js and es6-shim.min.js or should I also include es5-sham.min.js and es6-sham.min.js?

包含 es5-shim.min.js 和 es6-shim.min.js 是否足够,或者我还应该包含 es5-sham.min.js 和 es6-sham.min.js?

采纳答案by Joachim Sauer

According to this Github pagethe shims include all monkey-patches that faithfully represent the ES5 features.

根据这个 Github 页面,垫片包括忠实地代表 ES5 功能的所有猴子补丁。

In other words: you can use the features provided by these files as if you were using ES5 proper.

换句话说:您可以像使用 ES5 一样使用这些文件提供的功能。

The shams, however contain those features that can not be emulated with other code. They basically provide the API, so your code doesn't crash but they don't provide the actual functionality.

然而,shams 包含那些无法用其他代码模拟的功能。它们基本上提供 API,因此您的代码不会崩溃,但它们不提供实际功能。

Which ones do you need? That depends on how you write your code. If you only use features provided by the shims, then include that. If you also want to (optionally) use features from the shams, then you need both of them.

你需要哪些?这取决于您如何编写代码。如果您只使用垫片提供的功能,则包括它。如果您还想(可选)使用 shams 中的功能,那么您需要同时使用它们。