JS May 25, 2020

ES2020的新功能

Words count 11k Reading time 10 mins.

原文地址

近年来,JavaScript 的发展非常迅速。 尤其是在2015 年 ES6 发布之后,情况变得更好。

现在 许多新的特性被提议包括在 ES2020版本中。好消息是这些已经已经敲定。 现在,...

Read article

JS December 12, 2019

你不知道的 JSON.stringify() 的威力

Words count 10k Reading time 9 mins.

原文地址

首先我们在开发的过程当中遇到这样一个处理数据的需求

const todayILearn = {
  _id: 1,
  content: '今天学习 JSON.stringify(),我很开心!',
  created_at: 'Mon Nov 25 2019 14:03:55 GMT+0800 (中国标准时间)',
  updated_at: 'Mon Nov 25 2019 16:03:55 GMT+0800 (中国标准时间)'
}...
Read article

JS August 08, 2019

在17道题中理解javascript的类型转换

Words count 9.6k Reading time 9 mins.

原文地址

类型转换是将值从一种类型转换为另一种类型的过程(比如字符串转数字,对象转布尔值等)。任何类型不论是原始类型还是对象类型都可以进行类型转换,JavaScript 的原始类型有:number, string, boolean, null, undefined, Symbol

true + false
12 / "6"
"number" + 15 + 3
15 + 3 + "number"
[1] > null
"...
Read article

JS August 01, 2019

JavaScript异步编程回调地狱的一些解决方案

Words count 9.6k Reading time 9 mins.

原文地址

异步编程在JavaScript中非常重要。过多的异步编程也带了回调嵌套的问题,本文会提供一些解决“回调地狱”的方法。

setTimeout(function(){
    console.log("延时触发")
},2000)
fs.readFile('./samp.txt','utf-8',function(res,error){
    console.log(res);
})

上面就是典型的回调函数...

Read article

JS July 24, 2019

通过一个问题学习map,filter,reduce语法

Words count 6.7k Reading time 6 mins.

这个问题不难,有的少侠可能会使用for循环来过滤出偶数,某些少侠可能会使用while循环,又或是使用数组自带的filter方法。

这里,我们先不考虑使用for和while这些迭代方法,我们选择使用数组自带的filter方法,如果使用filter方法的话,

const nums = [1,2,3,4,5,6,7,8,9,10];
// 过滤出所有奇数
nums.filter(num => num % 2 !== 0);

console.log(nums);

还是挺简单的对吧?

相信大部分少...

Read article
Load more
0%