Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

es5-shim和es5-sham #34

Open
youngwind opened this issue Mar 2, 2016 · 1 comment
Open

es5-shim和es5-sham #34

youngwind opened this issue Mar 2, 2016 · 1 comment

Comments

@youngwind
Copy link
Owner

起因

在做项目的时候发现ie8不兼容Array.prototype.forEach方法,找到了两个解决方案,jquery.each和es5-shim

解决方案

1. jquery.each

$.each(array, function(key, value){
   // array[key] === value;
});

2. es5-shim

第二种解决方案是检测是否有这个方法,如果没有,自定义它,es5-shim帮我们做好了这个事情。

安装

bower install es5-shim --save

使用

<script src="./es5-shim.js"></script>
<script src="./es5-sham.js"></script>
// load your script

参考资料:
http://stackoverflow.com/questions/412447/for-each-javascript-support-in-ie

@ian4hu
Copy link

ian4hu commented Nov 1, 2016

es5-shim 和 es5-sham 有什么区别 必须要一起用么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants