jsDemo05.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. </head>
  7. <body>
  8. <script>
  9. /*创建Object对象,调用Object函数*/
  10. var obj = new Object();
  11. obj.a=15;
  12. obj.b=66;
  13. console.log(obj.a);
  14. console.log(obj.b);
  15. /*正常的方式创建对象*/
  16. var obj1={
  17. name:"张三",
  18. age:25,
  19. sex:"男",
  20. eat:function (){
  21. return this.name+"在吃饭";
  22. }
  23. }
  24. console.log(obj1.name);
  25. console.log(obj1.age);
  26. console.log(obj1.sex);
  27. console.log(obj1.eat());
  28. var person={
  29. name:"张三",
  30. age:25,
  31. sex:"男",
  32. eat:function (){
  33. return this.name+"在吃饭";
  34. }
  35. }
  36. /*Math对象的常用方法*/
  37. var n1 = Math.max(15,8);
  38. console.log(n1);
  39. var str="张三";
  40. str.substring(0,3);
  41. var date=new Date();
  42. console.log(date)
  43. </script>
  44. </body>
  45. </html>