1. <script>
    2. var arr = [3,4,5,6];
    3. // filter 只要达到某个条件 就会返回一个新的数组
    4. var res = arr.filter(item=>{
    5. return item>4;
    6. })
    7. console.log(res)
    8. var students = [
    9. {name:"李四",age:"18岁"},
    10. {name:"李二",age:"11岁"},
    11. {name:"李五",age:"19岁"},
    12. {name:"王四",age:"22.4岁"}
    13. ]
    14. // 大于11岁 返回新的数组
    15. var newStudents = students.filter(item=>{
    16. return parseFloat(item.age)>11;
    17. })
    18. console.log(newStudents)
    19. </script>