12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <!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>
- //二维数组
- const result = Object.fromEntries([
- ['name','hi'],
- ['age','15,34,45']
- ])
- console.log(result) //{name:'hi',age:'15,34,45'}
- //Map
- const m = new Map()
- m.set('name','zhang')
- const result1 = Object.fromEntries(m)
- console.log(m)
- //es8中 Object.entries 对象转数组
- const arr = Object.entries({
- name:'zhang'
- })
- console.log(arr)
- //2、trimStart
- let str = ' hi '
- console.log(str)
- console.log(str.trimStart())
- console.log(str.trimEnd())
- console.log(str.trim())
- //3、flat、flatMap 数组的两个方法 平 将多维数组转低维数组
- const arr1 = [1,2,3,[4,5]]
- console.log(arr1.flat())
- const arr2 = [1,2,3,[4,5,[6,7]]]
- console.log(arr2.flat(2)) //2表示深度
- const arr3 = [1,2,3,4]
- const result2 = arr3.flatMap(item=>[item*10])
- console.log(result2)
- //4、Symbol.prototype.description
- let s = Symbol('beida')
- console.log(s.description) //beida
- </script>
- </body>
- </html>
|