12345678910111213141516171819202122232425262728293031323334353637383940 |
- <!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>
- //Object.is 判断两个值是否完全相等
- console.log(Object.is(123,123)) // true
- console.log(Object.is(NaN,NaN)) //true
- console.log(NaN === NaN) //false
- //Object.assgin 对象合并
- const config1 = {
- a:1,
- b:2
- }
- const config2 = {
- c:3,
- a:5
- }
- console.log(Object.assign(config1,config2)) //{a: 5, b: 2, c: 3}
- // Object.setPrototypeof 设置原型对象
- const school = {
- name:'qinghua'
- }
- const cities = {
- xiaoqu:['北京','上海']
- }
- Object.setPrototypeOf(school,cities)
- console.log(Object.getPrototypeOf(school))
- console.log(school)
- </script>
- </body>
- </html>
|