当前位置: 首页 > news >正文

做外贸如何选择网站网站在线生成app

做外贸如何选择网站,网站在线生成app,网站开发的文献,重庆哪家做网站好在学习低代码时,经常有粉丝会问,低代码需要什么基础,es6就是基础中的一项。我们本篇是做一个扫盲,可以让你对基础有一个概要性的了解,具体的每个知识点可以深入进行了解,再结合官方模板就会有一个不错的掌握…

在学习低代码时,经常有粉丝会问,低代码需要什么基础,es6就是基础中的一项。我们本篇是做一个扫盲,可以让你对基础有一个概要性的了解,具体的每个知识点可以深入进行了解,再结合官方模板就会有一个不错的掌握。

1 let和const

let:声明变量,具有块级作用域。
const:声明常量,值不能改变

let x = 5;
{let y = 10;
}
console.log(x);  // 输出 5
console.log(y);  // 报错:y is not defined
const PI = 3.14;
PI = 3.15;  // 报错:Assignment to constant variable.

2 模板字符串

使用反引号表示,方便字符串拼接和格式化

const name = 'Alice';
const age = 25;
const message = `Hello, ${name}. You are ${age} years old.`;
console.log(message);  // 输出:Hello, Alice. You are 25 years old.

3 函数的默认值

可以为函数的参数提供默认值

function greet(name = 'Guest') {return `Hello, ${name}!`;
}
console.log(greet());  // 输出:Hello, Guest!

4 剩余参数

允许接收不定数量的参数

function sum(...args) {let sum = 0;for (const num of args) {sum += num;}return sum;
}
console.log(sum(1, 2, 3, 4, 5));  // 输出:15

5 扩展运算符

扩展运算符(spread operator)用于将一个数组或对象的所有元素或属性展开。

let arr1 = [1, 2, 3];  
let arr2 = [...arr1, 4, 5]; // [1, 2, 3, 4, 5]  let obj1 = { a: 1, b: 2 };  
let obj2 = { ...obj1, c: 3 }; // { a: 1, b: 2, c: 3 }

6 箭头函数

箭头函数提供了一种更加简洁的函数书写方式,它没有自己的this、arguments、super或new.target。箭头函数内的this值继承自外围作用域。

let numbers = [1, 2, 3];  
numbers.forEach((num) => console.log(num)); // 输出每个数字  let obj = {  value: 10,  getValue: () => console.log(this.value)  
};  
obj.getValue(); // 输出 undefined,因为箭头函数不绑定自己的this,这里的this指向全局对象

7 箭头函数的this指向

箭头函数不会创建自己的this上下文,所以this引用的是定义箭头函数时的上下文。

function Outer() {  this.value = 1;  this.inner = () => {  console.log(this.value); // 输出 1,这里的this指向Outer的实例  };  
}  let outer = new Outer();  
outer.inner(); // 输出 1

8 解构赋值

解构赋值是一种JavaScript表达式,它可以将值从数组或对象中提取到不同的变量中。

let [a, b, ...rest] = [1, 2, 3, 4, 5]; // a = 1, b = 2, rest = [3, 4,5]
let { name, age } = { name: "Alice", age: 30 }; // name = "Alice", age = 30

9 对象字面量的属性简写

在ES6中,如果对象字面量的属性名和变量名相同,可以直接使用变量名作为属性名。

let name = "Alice";  
let age = 30;  let person = {  name, // 等同于 name: name  age, // 等同于 age: age  
};  console.log(person); // 输出 { name: "Alice", age: 30 }

10 对象字面量的方法简写

在ES6中,对象字面量中的方法可以直接使用函数名作为方法名,而不需要使用冒号和函数关键字。

let person = {  name: "Alice",  greet() {  console.log(`Hello, my name is ${this.name}.`);  }  
};  person.greet(); // 输出 "Hello, my name is Alice."

11 Symbol类型

Symbol是一种新的原始数据类型,表示一个唯一的、不可变的值。

let sym1 = Symbol("key1");  
let sym2 = Symbol("key1");  console.log(sym1 === sym2); // 输出 false,因为sym1和sym2是不同的Symbol值  let obj = {};  
obj[sym1] = "value1";  
console.log(obj[sym2]); // 输出 undefined,因为sym1和sym2是不同的Symbol值

12 Set和Map

Set和Map是ES6中引入的两种新的集合类型。

Set是一种值的集合,它类似于数组,但成员的值都是唯一的,没有重复的值。

let set = new Set([1, 2, 2, 3, 4, 4, 5]);  
console.log(set); // Set { 1, 2, 3, 4, 5 }

Map是一种键值对的集合,任何值(对象或者基本类型)都可以作为一个键或一个值。

let map = new Map();  
map.set('key', 'value');  
console.log(map.get('key')); // 输出 "value"

13 数组的扩展方法

提供了许多方便的方法,如filter()、map()、reduce()等

const array = [1, 2, 3, 4, 5];
const evenNumbers = array.filter(num => num % 2 === 0);
const doubledNumbers = array.map(num => num * 2);
const sumOfNumbers = array.reduce((accumulator, current) => accumulator + current, 0);

14 迭代器

迭代器(Iterator)是一个对象,它定义了一个序列,并且有一定的访问规则。任何具有Symbol.iterator属性的对象都是可迭代的。

let arr = [1, 2, 3];  
let iterator = arr[Symbol.iterator]();  
iterator.next(); // { value: 1, done: false }

15 生成器

生成器(Generator)是一种特殊的迭代器,可以暂停执行和恢复执行。它使用function*语法定义,并使用yield表达式输出。

function* generator() {  yield 1;  yield 2;  yield 3;  
}  let gen = generator();  
gen.next(); // { value: 1, done: false }  
gen.next(); // { value: 2, done: false }

16 Promise

Promise是处理异步操作的一种对象,它代表了可能现在、将来或永远不会完成的操作及其结果值。

let promise = new Promise((resolve, reject) => {  // 异步操作  setTimeout(() => resolve('Success!'), 1000);  
});  promise.then(result => console.log(result)); // 输出 "Success!"

17 async/await

async/await是建立在Promise上,用于处理异步操作的新语法,使得异步代码看起来和同步代码一样。

async function asyncFunc() {  return new Promise(resolve => setTimeout(resolve, 1000, 'Async result!'));  
}  async function main() {  let result = await asyncFunc();  console.log(result); // 输出 "Async result!"  
}  
main();

18 类

ES6引入了类的概念,用于对象的原型式继承。类提供了一种更加清晰、面向对象的方式来组织代码。

class Person {  constructor(name) {  this.name = name;  }  greet() {  console.log(`Hello, my name is ${this.name}.`);  }  
}  let alice = new Person('Alice');  
alice.greet(); // 输出 "Hello, my name is Alice."

19 模块

ES6引入了模块的概念,允许将代码分割成独立的文件,然后在其他文件中引入使用。
moduleA.js

export function greet() {  console.log('Hello from module A!');  
}

moduleB.js

import { greet } from './moduleA.js';  
greet(); // 输出 "Hello from module A!"

文章转载自:
http://noncom.sqLh.cn
http://similitude.sqLh.cn
http://patchy.sqLh.cn
http://coccid.sqLh.cn
http://decertify.sqLh.cn
http://vojvodina.sqLh.cn
http://colourless.sqLh.cn
http://robotize.sqLh.cn
http://churchman.sqLh.cn
http://corrosible.sqLh.cn
http://electroosmosis.sqLh.cn
http://antiquer.sqLh.cn
http://kummerbund.sqLh.cn
http://wilma.sqLh.cn
http://turrethead.sqLh.cn
http://utilitarian.sqLh.cn
http://arminianism.sqLh.cn
http://metacarpal.sqLh.cn
http://cryoscopic.sqLh.cn
http://letterweight.sqLh.cn
http://mas.sqLh.cn
http://schizothymic.sqLh.cn
http://quartzose.sqLh.cn
http://rhythmed.sqLh.cn
http://butskell.sqLh.cn
http://crested.sqLh.cn
http://smelly.sqLh.cn
http://introduction.sqLh.cn
http://mightiness.sqLh.cn
http://eslisor.sqLh.cn
http://officialize.sqLh.cn
http://orphan.sqLh.cn
http://nonsugar.sqLh.cn
http://rhizomatic.sqLh.cn
http://jowett.sqLh.cn
http://discomposed.sqLh.cn
http://geocarpy.sqLh.cn
http://hitfest.sqLh.cn
http://yarovise.sqLh.cn
http://osmiridium.sqLh.cn
http://twentieth.sqLh.cn
http://semiyearly.sqLh.cn
http://serve.sqLh.cn
http://arum.sqLh.cn
http://grommet.sqLh.cn
http://desperation.sqLh.cn
http://hemiplegia.sqLh.cn
http://impressionable.sqLh.cn
http://rtl.sqLh.cn
http://thunderstruck.sqLh.cn
http://psephomancy.sqLh.cn
http://obdurate.sqLh.cn
http://ascensiontide.sqLh.cn
http://sjambok.sqLh.cn
http://paralyse.sqLh.cn
http://sponger.sqLh.cn
http://stockman.sqLh.cn
http://appreciably.sqLh.cn
http://ionization.sqLh.cn
http://hyperpiesia.sqLh.cn
http://anathematic.sqLh.cn
http://vair.sqLh.cn
http://rebelliousness.sqLh.cn
http://assertively.sqLh.cn
http://proteide.sqLh.cn
http://canadien.sqLh.cn
http://perfunctorily.sqLh.cn
http://filarial.sqLh.cn
http://encumber.sqLh.cn
http://microtexture.sqLh.cn
http://visionless.sqLh.cn
http://geometer.sqLh.cn
http://theca.sqLh.cn
http://tiffin.sqLh.cn
http://klong.sqLh.cn
http://sniper.sqLh.cn
http://carbonari.sqLh.cn
http://nectarous.sqLh.cn
http://isogamy.sqLh.cn
http://hypertensive.sqLh.cn
http://pondage.sqLh.cn
http://warranty.sqLh.cn
http://incflds.sqLh.cn
http://gametophore.sqLh.cn
http://univariate.sqLh.cn
http://imageless.sqLh.cn
http://inobservantly.sqLh.cn
http://superstitiously.sqLh.cn
http://habitue.sqLh.cn
http://swarthiness.sqLh.cn
http://offenseful.sqLh.cn
http://fluor.sqLh.cn
http://excisable.sqLh.cn
http://etiolation.sqLh.cn
http://hnrna.sqLh.cn
http://anacreon.sqLh.cn
http://currycomb.sqLh.cn
http://glim.sqLh.cn
http://hippy.sqLh.cn
http://glycogen.sqLh.cn
http://www.15wanjia.com/news/64319.html

相关文章:

  • wordpress影视自采集模板广州seo公司如何
  • 公司网页制作网站数据分析师报考官网
  • 200万做网站学百度推广培训
  • 产品经理兼职做网站报酬搜索引擎关键词优化技巧
  • 新开传奇网站新开网北京发生大事了
  • 网页广告多少钱海外网站推广优化专员
  • 在哪里建网站google seo怎么做
  • 海南医院网站建设百度域名
  • 公司网站的主页优化纯注册app拉新平台
  • 国内flash网站网站推广的基本方法为
  • 图片瀑布流网站模板大连seo优化
  • 联盟或专业团体的官方网站的建设北京谷歌seo
  • 惠州房地产网站开发香港域名注册网站
  • 天元建设集团有限公司网站添加友情链接的技巧
  • 莆田网站建设地推团队
  • asp.net做学校网站首页百度引擎搜索推广
  • 网站更改备案信息在哪湖北网络推广seo
  • 红酒营销型网站建设搜索推广渠道有哪些
  • 怎么在互联网做网站郑州网站运营专业乐云seo
  • 沈阳做网站公司企业网站seo方案案例
  • 做电影网站都需要什么工具深圳网站建设专业乐云seo
  • 做网站框架可用jpg图吗搜索引擎seo如何优化
  • 新闻最新消息10条湛江seo推广公司
  • 邯郸做网站哪儿好网址收录入口
  • 延吉做网站ybdiran发稿媒体平台
  • 网站源码大全百度指数的主要功能有
  • 中山建网站找哪家谷歌商店下载官方
  • 深圳网站建设 设计贝尔利网站维护的内容有哪些
  • 郑州网络营销推广公司网络seo推广培训
  • 企业网站的设计风格百度app下载官方免费下载最新版