index.html 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. //Object.is 判断两个值是否完全相等
  12. console.log(Object.is(123,123)) // true
  13. console.log(Object.is(NaN,NaN)) //true
  14. console.log(NaN === NaN) //false
  15. //Object.assgin 对象合并
  16. const config1 = {
  17. a:1,
  18. b:2
  19. }
  20. const config2 = {
  21. c:3,
  22. a:5
  23. }
  24. console.log(Object.assign(config1,config2)) //{a: 5, b: 2, c: 3}
  25. // Object.setPrototypeof 设置原型对象
  26. const school = {
  27. name:'qinghua'
  28. }
  29. const cities = {
  30. xiaoqu:['北京','上海']
  31. }
  32. Object.setPrototypeOf(school,cities)
  33. console.log(Object.getPrototypeOf(school))
  34. console.log(school)
  35. </script>
  36. </body>
  37. </html>