JavaScript笔记无偿分享——拓新篇
arr.length
语法糖
【在编程语言中,为了让代码更易于编写和阅读,而添加的一些语法特性,这些特性并不会带来新的功能,只是对现有功能的一种更简洁、更方便的表达方式。】
箭头函数
(适合匿名函数)
function (x) { return x + 1; }
可以写成箭头函数(x) => x + 1;
解构赋值
let arr = [1, 2, 3];
let a = arr[0]; let b = arr[1]; let c = arr[2];
可以写成let [a, b, c] = arr;
字符串模板
let name = ‘John’; let greeting = ‘Hello,’+ name + ‘!’;
可以写成let greeting = Hello, ${name}!;