JavaScript EventEmitter

2018-03-25
阅读 12 分钟
1.4k
上个周末花点时间根据之前看源码的理解自己用 ES6 实现了一个 eventemitter8,然后也发布到 npm 上了,让我比较意外的是才发布两天在没有 readme 介绍,没有任何宣传的情况下居然有45个下载,我很好奇都是谁下载的,会不会用。我花了不少时间半抄半原创的一个 JavaScript 时间处理库 now.js (npm 传送门:now.js) ,在我...

JavaScript30秒, 从入门到放弃之Array(七)

2018-02-19
阅读 10 分钟
1.5k
Filters out the elements of an array, that have one of the specified values. Use Array.filter() to create an array excluding(using !Array.includes()) all given values. {代码...}

JavaScript30秒, 从入门到放弃之Array(六)

2018-02-10
阅读 9 分钟
1.8k
Returns all elements in an array except for the first one. Return Array.slice(1) if the array's length is more than 1, otherwise, return the whole array. {代码...}

JavaScript30秒, 从入门到放弃之Array(五)

2018-02-09
阅读 11 分钟
1.1k
Gets n random elements at unique keys from array up to the size of array. Shuffle the array using the Fisher-Yates algorithm. Use Array.slice() to get the first n elements. Omit the second argument, n to get only one element at random from the array. {代码...}

JavaScript30秒, 从入门到放弃之Array(四)

2018-01-20
阅读 12 分钟
1.4k
Returns the n maximum elements from the provided array. If n is greater than or equal to the provided array's length, then return the original array(sorted in descending order). Use Array.sort() combined with the spread operator (...) to create a shallow clone of the array and sort it in descendi...

JavaScript30秒, 从入门到放弃之Array(三)

2017-12-31
阅读 8 分钟
1.5k
Flattens an array up to the specified depth. Use recursion, decrementing depth by 1 for each level of depth. Use Array.reduce() and Array.concat() to merge elements or arrays. Base case, for depth equal to 1 stops recursion. Omit the second element, depth to flatten only to a depth of 1 (single f...

JavaScript30秒, 从入门到放弃之Array(二)

2017-12-26
阅读 6 分钟
1.3k
Returns the difference between two arrays. Create a Set from b, then use Array.filter() on a to only keep values not contained in b. {代码...}

JavaScript30秒, 从入门到放弃

2017-12-24
阅读 6 分钟
4k
有意思 最近很火的github上的库30-seconds-of-code,特别有意思,代码也很优雅。 能学es6 自己翻译,能学英语 代码很美,很优雅,美即正义 函数式表达,享受 arrayGcd Calculates the greatest common denominator (gcd) of an array of numbers. Use Array.reduce() and the gcd formula (uses recursion) to calculate...

now.js 迷你版发布

2017-12-05
阅读 1 分钟
2.2k
迷你版即0.3.0版。0.2.0版没加新功能,只增加eadme内容和修正package.json上的一些错误。0.3.0同样没加新功能,但是却是非常重要的。这个版本国际化默认只支持英文和中文。初始化是英文。如果想支持全部118种语言,需要引入nowjs.locale.js或者压缩版nowjs.locale.min.js。

now.js 0.1.0 发布了

2017-12-04
阅读 4 分钟
2.7k
因为学习underscore源码的过程中,感觉无聊。想写个库调剂一下,当做学习的机会。我是照着underscore源码一个个commit敲的.代码放在这里,刚看了一眼,有668次commit,两个月,敲到了1.4.3版本,可能还没到一半。敲久了有点无聊。想动手写一个库作为调剂。碰巧之前做防健忘短信提醒的时候是用go写的后台,用了gorm,在作...