Returns true if the given string contains any whitespace characters, false otherwise.

Use RegExp.prototype.test() with an appropriate regular expression to check if the given string contains any whitespace characters.

继续阅读 30秒学会 JavaScript 片段 – containsWhitespace

Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.

Use Array.prototype.reduce() to calculate how many numbers are below the value and how many are the same value and apply the percentile formula.

继续阅读 30秒学会 JavaScript 片段 – percentile

Creates an array of elements, grouped based on the position in the original arrays.

Use Math.max.apply() to get the longest array in the arguments.
Creates an array with that length as return value and use Array.from() with a map-function to create an array of grouped elements.
If lengths of the argument-arrays vary, undefined is used where no value could be found.

继续阅读 30秒学会 JavaScript 片段 – zip

Mutates the original array to filter out the values specified.

Use Array.prototype.filter() and Array.prototype.includes() to pull out the values that are not needed.
Use Array.prototype.length = 0 to mutate the passed in an array by resetting it’s length to zero and Array.prototype.push() to re-populate it with only the pulled values.

继续阅读 30秒学会 JavaScript 片段 – pull