随笔分类 - javascript
摘要:ES6如下描述: 字符串 静态字符串一律使用单引号或反引号,不使用双引号。动态字符串使用反引号。 // bad const a = "foobar"; const b = 'foo' + a + 'bar'; // acceptable const c = `foobar`; // good con
阅读全文
摘要:在let和const之间,建议优先使用const,尤其是在全局环境,不应该设置变量,只应设置常量:原因如下2) (1)let 取代 var ES6 提出了两个新的声明变量的命令:let和const。其中,let完全可以取代var,因为两者语义相同,而且let没有副作用。 在let和const之间,建
阅读全文
摘要:[] 中括号可以用来取对象 例如: obj[name]取的是obj对象中的name值 [pointData]取的是当前作用域内的pointData对象 例子: const pointHandelChange = (e) => { console.log(e.target); const { name
阅读全文
摘要:数组对象: 对于获取数组的最后一个元素,可能平常见得多的就是arr[arr.length - 1],我们其实可以使用at()方法进行获取 接收一个整数值并返回该索引对应的元素: const arr = [5, 12, 8, 130, 44]; let index1 = 2; strt1 = `索引号
阅读全文