From e6c1427412ccc5070c2b3b9df9065d8308771eac Mon Sep 17 00:00:00 2001 From: Siarhei Date: Wed, 5 Sep 2018 18:31:52 +0400 Subject: [PATCH 1/2] Using more declarative way to create array in nodeListToArray --- snippets/nodeListToArray.md | 2 +- test/nodeListToArray/nodeListToArray.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/nodeListToArray.md b/snippets/nodeListToArray.md index d5c8713d1..22b408ce0 100644 --- a/snippets/nodeListToArray.md +++ b/snippets/nodeListToArray.md @@ -5,7 +5,7 @@ Converts a `NodeList` to an array. Use `Array.prototype.slice()` and `Function.prototype.call()` to convert a `NodeList` to an array. ```js -const nodeListToArray = nodeList => Array.prototype.slice.call(nodeList); +const nodeListToArray = nodeList => [...nodeList]; ``` ```js diff --git a/test/nodeListToArray/nodeListToArray.js b/test/nodeListToArray/nodeListToArray.js index 0b834e1ae..2fc92fad0 100644 --- a/test/nodeListToArray/nodeListToArray.js +++ b/test/nodeListToArray/nodeListToArray.js @@ -1,2 +1,2 @@ -const nodeListToArray = nodeList => Array.prototype.slice.call(nodeList); +const nodeListToArray = nodeList => [...nodeList]; module.exports = nodeListToArray; From 10fd881b1e486633c3908ba4bca994660adf100e Mon Sep 17 00:00:00 2001 From: Siarhei Date: Wed, 5 Sep 2018 18:36:06 +0400 Subject: [PATCH 2/2] Change docs for nodeListToArray --- snippets/nodeListToArray.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/nodeListToArray.md b/snippets/nodeListToArray.md index 22b408ce0..1f41b0a76 100644 --- a/snippets/nodeListToArray.md +++ b/snippets/nodeListToArray.md @@ -2,7 +2,7 @@ Converts a `NodeList` to an array. -Use `Array.prototype.slice()` and `Function.prototype.call()` to convert a `NodeList` to an array. +Use spread operator inside new array to convert a `NodeList` to an array. ```js const nodeListToArray = nodeList => [...nodeList];