30秒学会 JavaScript 片段 – compact
Removes falsy values from an array. Use Array.prototype.filter() to filter out falsy values (false, ...
Removes falsy values from an array. Use Array.prototype.filter() to filter out falsy values (false, ...
Returns every element that exists in any of the two arrays once. Create a Set with all values of a a...
Checks if the provided string is a valid JSON. Use JSON.parse() and a try… catch block to check if...
Returns the target value in a nested JSON object, based on the given key. Use the in operator to che...
Performs left-to-right function composition. Use Array.prototype.reduce() to perform left-to-right f...
Escapes a string to use in a regular expression. Use String.prototype.replace() to escape special ch...
Pads a string on both sides with the specified character, if it’s shorter than the specified l...
Runs an array of promises in series. Use Array.prototype.reduce() to create a promise chain, where e...
Results in a string representation of yesterday’s date. Use new Date() to get the current date...
Returns the nth element of an array. Use Array.prototype.slice() to get an array containing the nth ...