xiaomao Feng

Results 22 issues of xiaomao Feng

## getType > Returns the native type of a value. > > Returns lowercased constructor name of value, "undefined" or "null" if value is undefined or null. > > ```javascript...

2个多月前把 Github 上的 [eventemitter3](https://github.com/primus/eventemitter3) 和 `Node.js` 下的事件模块 [events](https://github.com/nodejs/node/blob/master/lib/events.js) 的源码抄了一遍,才终于对 `JavaScript` 事件有所了解。 上个周末花点时间根据之前看源码的理解自己用 ES6 实现了一个 [eventemitter8](https://github.com/hongmaoxiao/eventemitter8),然后也发布到 [npm](https://www.npmjs.com/package/eventemitter8) 上了,让我比较意外的是才发布两天在没有 `readme` 介绍,没有任何宣传的情况下居然有45个下载,我很好奇都是谁下载的,会不会用。我花了不少时间半抄半原创的一个 `JavaScript` 时间处理库 [now.js](https://github.com/hongmaoxiao/now) (`npm` 传送门:[now.js](https://www.npmjs.com/package/now.js)) ,在我大力宣传的情况下,4个月的下载量才[177](https://npm-stat.com/charts.html?package=now.js&from=2017-10-16&to=2018-03-14)。真是`有心栽花花不开,无心插柳柳成荫`! `eventemitter8` 大部分是我根据看源码理解后写出来的,有一些方法如`listeners`,`listenerCount` 和 `eventNames` 一下子想不起来到底做什么,回头重查。测试用例不少是参考了...

## without > 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....

## tail > 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...

## sampleSize > Gets `n` random elements at unique keys from `array` up to the size of `array`. > > Shuffle the array using the [Fisher-Yates algorithm](https://github.com/chalarangelo/30-seconds-of-code#shuffle). Use `Array.slice()` to...

> 欢迎大家点右上角的watch,第一时间接收新文章发布消息,我会将这个系列坚持翻译完! ## maxN > 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...

## flattenDepth > 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...

## difference > 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`. >...

# 有意思 最近很火的`github`上的库[`30-seconds-of-code`](https://github.com/Chalarangelo/30-seconds-of-code),特别有意思,代码也很优雅。 1. 能学es6 2. 自己翻译,能学英语 3. 代码很美,很优雅,美即正义 4. 函数式表达,享受 ## arrayGcd > Calculates the greatest common denominator (gcd) of an array of numbers. > > Use `Array.reduce()` and...

## 迷你版 迷你版即0.3.0版。 0.2.0版没加新功能,只增加eadme内容和修正package.json上的一些错误。 0.3.0同样没加新功能,但是却是非常重要的。 这个版本国际化默认只支持英文和中文。初始化是英文。如果想支持全部118种语言,需要引入[nowjs.locale.js](https://github.com/hongmaoxiao/now/tree/master/dist/nowjs.locale.js)或者压缩版[nowjs.locale.min.js](https://github.com/hongmaoxiao/now/tree/master/dist/nowjs.min.locale.js)。 ## 版本大小比较 ``` ~/learn/ljs/now master ❯ ll -h dist | grep js$ -rw-rw-r-- 1 mao mao 66K 12月 5 00:37 nowjs.js -rw-rw-r-- 1 mao...