![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
javascript
Web_workstart
这个作者很懒,什么都没留下…
展开
-
JavaScript里的for in与 for of
for …in 遍历 键名;遍历对象的整个原型链,性能差数组不太适用!// 遍历对象 i 是 key, a 是 对象本身let a = {name: 'zs', age: 18, sex: 'man'};for(let i in a) { console.log(i + '---' + a[i])} // name---zs age---18 sex---man// 遍历数组 不建议不建议不建议let a = [1, 3, 5, 7, 9];for(let i in a) .原创 2020-07-16 17:10:45 · 190 阅读 · 0 评论 -
JavaScript的数组去重,累加的小方法
数组去重的俩个小方法; filter() 和 indexOf() 相结合// Array.from() 和 new Set() 相结合let arr = [1, 2, 2, 2, 3, 3, 1];let newArr =原创 2020-07-15 10:14:45 · 803 阅读 · 0 评论 -
JavaScript里的一些数组方法
forEach() 遍历数组,遍历.length次数let arr = [1, 2, 3];arr.forEach((item, index, array) => { console.log(item, index, array)})// 回调函数里的参数:数组元素, 数组索引,数组本身filter() 筛选数组,根据筛选条件返回新数组, 不改变原数组let arr = [1, 2, 3];let newArr = arr.filter((item, index, a.原创 2020-07-14 17:57:28 · 120 阅读 · 0 评论 -
短路运算(逻辑中断),条件判断
短路运算(逻辑中断)左边的 表达式/值 为true时,才计算 右边; 左边为 false 时,直接退出运算console.log(3>5 && 2>1) 左边和右边的 表达式/值 谁为true时 返回谁console.log(3>5 || 2>1)...原创 2020-06-22 10:08:47 · 515 阅读 · 0 评论 -
简单数据类型转换,获取数据类型,数字型的特殊值,
1. var 定义变量 undefined: 未定义 : 只声明未赋值,值未定义 not defined : 没有定义: 变量没有定义JavaScript中数值的最大和最小值最大值:Number.MAX_VALUE,这个值是 (10的正308次方)即1.7976931348623157e+308最小值:Number.MIN_VALUE,这个值为是 (10的负324次方)即5e-32数字型的三个特殊值- Infinity ,代表无穷大,大于任何数值- -Infinity.原创 2020-06-04 18:21:25 · 214 阅读 · 0 评论