04_js.html 618 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>入门</title>
  6. </head>
  7. <body>
  8. <script>
  9. //自定义对象
  10. let person = {
  11. //属性
  12. name : "zs",
  13. age : 22,
  14. studay : function (){
  15. console.log("学习方法")
  16. }
  17. }
  18. //使用
  19. console.log("名称:"+person.name);
  20. person.address = "北京"
  21. console.log("地址:"+person.address);
  22. //方法
  23. person.studay()
  24. person.eat = function (){
  25. console.log("干饭人")
  26. }
  27. person.eat()
  28. </script>
  29. </body>
  30. </html>