This commit is contained in:
Angelos Chalaris
2017-12-18 15:50:56 +02:00
parent c30efa3d38
commit 4a8f6b83a9
2 changed files with 4 additions and 4 deletions

View File

@ -446,8 +446,8 @@ Omit the second argument, `n`, to get the first element of the array.
```js
const nthElement = (arr, n=0) => (n>0? arr.slice(n,n+1) : arr.slice(n))[0];
// nth(['a','b','c'],1) -> 'b'
// nth(['a','b','b']-2) -> 'a'
// nthElement(['a','b','c'],1) -> 'b'
// nthElement(['a','b','b'],-3) -> 'a'
```
[⬆ back to top](#table-of-contents)

View File

@ -317,8 +317,8 @@ squareIt([1,2,3]) // { 1: 1, 2: 4, 3: 9 }
If the index is out of bounds, return <code>[]</code>.
Omit the second argument, <code>n</code>, to get the first element of the array.</p>
<pre><code class="language-js">const nthElement = (arr, n=0) =&gt; (n&gt;0? arr.slice(n,n+1) : arr.slice(n))[0];
// nth(['a','b','c'],1) -&gt; 'b'
// nth(['a','b','b']-2) -&gt; 'a'
// nthElement(['a','b','c'],1) -&gt; 'b'
// nthElement(['a','b','b'],-3) -&gt; 'a'
</code></pre>
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="pick">pick</h3></div><div class="section double-padded">
<p>Picks the key-value pairs corresponding to the given keys from an object.</p>