JavaScript find 方法不支持IE


最近在前端開發中,遇到一個JavaScript 的問題。

    <script type="text/javascript">
        var arrayList = new Array();
        arrayList.push(1);
        arrayList.push(2);
        arrayList.push(3);
        arrayList.push(4);

        arrayList.find(function (val) {
            if (val == 4) {
                console.log('This is a test');
            }
        });
    </script>

用Chrome,Firefox,運行結果正常。但是在IE里面確出現了"對象不支持find屬性或方法"的錯誤.


看了下官方文檔才發現他是不支持IE的。
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM