You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
563 B

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. // js 中的 typeof
  2. // console.log(typeof 'hello TS')
  3. // TS 中的 typeof
  4. let p = { x: 1, y: 2 }
  5. // function formatPoint(point: {x: number; y: number }) {}
  6. <<<<<<< HEAD
  7. // 使用 typeof
  8. =======
  9. <<<<<<< HEAD
  10. // 使用 typeof
  11. =======
  12. <<<<<<< HEAD
  13. // 使用 typeof
  14. =======
  15. // 使用 typeof,拿到对象 p 中的类型,实现简化书写的目的
  16. >>>>>>> ceebe04 (TypeScript)
  17. >>>>>>> 609bdbe (TypeScript)
  18. >>>>>>> a25358e (TypeScript)
  19. function formatPoint(point: typeof p ) {}
  20. formatPoint({ x: 1, y: 100 })
  21. // 查看 p对象中属性 x
  22. let num: typeof p.x