Blogger Information
Blog 2
fans 0
comment 0
visits 824
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
获取焦点提示以及失去焦点提示
卢浩良
Original
356 people have browsed it

<!DOCTYPE html>

<html lang="en">

  <head>

    <meta charset="UTF-8" />

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>Document</title>

  </head>

  <body>

    <script>

      let arr = [1, 9, 3, 4, 5]

      //reduce  进行累加

      let res4 = arr.reduce((acc, item, index, arr) => acc + item)

      console.log(res4)

      //遍历数组

      let res = arr.forEach(function (item, index, arr) {

        console.log(item, index, arr)

      })

      console.log(res)

      //进行降序排列

      let res1 = arr.sort(function (a, b) {

        return b - a

      })

      console.log(res1)

      //取数

      let res2 = arr.slice(2, 5)

      console.log(res2)

      //splice 进行删除

      //console.log(arr)

      let res3 = arr.splice(1, 2)

      console.log(arr)

      console.log(arr.splice(1, 0, 'red', 'green'))

      console.log(arr)

    </script>

  </body>

</html>



Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post