Pads a string on both sides with the specified character, if it’s shorter than the specified length.

Use String.prototype.padStart() and String.prototype.padEnd() to pad both sides of the given string.
Omit the third argument, char, to use the whitespace character as the default padding character.

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

Returns the nth element of an array.

Use Array.prototype.slice() to get an array containing the nth element at the first place.
If the index is out of bounds, return undefined.
Omit the second argument, n, to get the first element of the array.

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

Returns the n maximum elements from the provided list.
If n is greater than or equal to the provided list’s length, then return the original list (sorted in descending order).

Use sorted() to sort the list, [:n] to get the specified number of elements.
Omit the second argument, n, to get a one-element list.

继续阅读 30秒学会 Python 片段 – max_n