Blogger Information
Blog 7
fans 0
comment 0
visits 3947
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
变量,常量,数据类型, 函数
冷风
Original
494 people have browsed it

变量,常量,数据类型, 函数

变量

  • 用let声明,它第一次赋值叫初始化,第二次叫更新
  1. let Abc = "123456";
  2. Abc = "23456";
  3. console.log(Abc);

常量

  • 常量不能被更新,所以必须给予赋值
  1. const Ac = "5555";

数据类型

  • 数据类型有原始类型,引用函数,引用对象,引用数组
  1. 原始类型
  2. const Ac = "name";
  3. 函数也是对象,函数也可以当成值来传递和引用
  4. function Ac(a, b, c) {}
  5. console.dir(Ac);
  6. Ac.email = "123456@qq.com";
  7. 引用对象
  8. const Ac = {
  9. name: "1111",
  10. gender: "2222",
  11. job: "3333",
  12. getName: function () {
  13. return this.name;
  14. },
  15. };
  16. 引用数组
  17. const Ac = ["111", "222", "333"];

函数参数与返回值

  1. let Ac = function (...arr) {
  2. return arr.reduce((p, c) => p + c);
  3. };
  4. console.log(Ac(1, 2, 3, 4, 5));

匿名函数及箭头函数的转化

  1. let Ac = (a, b) => {
  2. return a + b;
  3. };
  4. console.log(Ac(10, 10));
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