Blogger Information
Blog 12
fans 0
comment 0
visits 5456
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js 数据类型,函数类型
。。。
Original
492 people have browsed it

js 数据类型,函数类型

  1. //数据类型
  2. let gende; //未初始化变量的默认值 undeifned
  3. let age = 10; //整数
  4. let num = 1.11; //小数
  5. let name = "DDDD"; //字符串
  6. let isMarr = true; //布尔
  7. //符号,创建对象属性的唯一标识
  8. let s Symbol('custom symbol');
  9. console.log(s,typeof s);
  10. //使用typeof 检测数据类型
  11. console.log(age,typeof age);
  12. //字符串拼接使用”+“号
  13. console.log('邮箱' + email);
  14. //值传递
  15. let a = 100;
  16. // 将变量的a的值,传递到了b;
  17. let b = a;
  18. console.log(b);
  19. let a = 200;
  20. console.log(b);
  21. // a的更新不会影响到b
  22. //对象字面量
  23. let user = {
  24. // 属性,相当于变量
  25. id:1,
  26. name:'zhangzhongguo',
  27. 'my email':'123456@qq.con',
  28. // 方法:函数
  29. getName:function(){
  30. //this表示当前的上下文,当前对象
  31. return '我的名字叫:'+ this.name;
  32. }
  33. }
  34. console.log(user.id,user.name);
  35. console.log(user['my email']);
  36. console.log(user.getName());
  37. //数组
  38. let course = [5,'javascript','php.cn'];
  39. //访问数组中的第二个值
  40. console.log(course[1]);
  41. //函数
  42. function hello(){}
  43. console.log(hello,typeof hello);
  44. console.log(hello,instanceof Object);
  45. // 对象是属性的无序集合,对象可以添加属性
  46. hello.email = '123456@qq.com';
  47. console.log(hello.email);
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post