Shim vs. Sham: What is the difference?

JavascriptEcmascript 5Ecmascript 6Polyfills

Javascript Problem Overview


What is the difference between a shim an a 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?

Javascript Solutions


Solution 1 - Javascript

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

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

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.

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongarbanzioView Question on Stackoverflow
Solution 1 - JavascriptJoachim SauerView Answer on Stackoverflow