函数在对象中作为方法的语法(三种)

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Document</title>
    7. </head>
    8. <body>
    9. <script>
    10. // 函数在对象中作为方法的语法(三种)
    11. var obj = {
    12. name:"shang",
    13. sayName(){
    14. console.log(this.name)
    15. },
    16. sayAge:()=>{
    17. console.log(18)
    18. },
    19. saySkill:function(){
    20. console.log("javascript")
    21. }
    22. }
    23. </script>
    24. </body>
    25. </html>