What's happening here is that you call slice() as if it was a function of NodeList using call(). What slice() does in this case is create an empty array, then iterate through the object it's running on (originally an array, now a NodeList) and keep appending the elements of that object to the empty array it created, which is eventually returned. Here's an article on this.

EDIT:

So it starts with an empty array [], then slice is used to convert the result of call to a new array yeah?

That's not right. [].slice returns a function object. A function object has a function call() which calls the function assigning the first parameter of the call() to this; in other words, making the function think that it's being called from the parameter (the NodeList returned by document.querySelectorAll('a')) rather than from an array.

Answer from Max Shawabkeh on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › slice
Array.prototype.slice() - JavaScript | MDN
The slice() method of Array instances returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.
🌐
W3Schools
w3schools.com › jsref › jsref_slice_array.asp
JavaScript Array slice() Method
The slice() method returns selected elements in a new array.
Discussions

arrays - Explanation of [].slice.call in javascript? - Stack Overflow
I actually saw this pattern appear ... var slice = array.slice; var splice = array.splice; Does he do this for the safety issue @MathiasBynens mentions? 2014-07-18T17:39:37.173Z+00:00 ... Save this answer. ... Show activity on this post. In JavaScript, methods of an object can ... More on stackoverflow.com
🌐 stackoverflow.com
arrays - How can I slice an object in Javascript? - Stack Overflow
I was trying to slice an object using Array.prototype, but it returns an empty array, is there any method to slice objects besides passing arguments or is just my code that has something wrong? Thx... More on stackoverflow.com
🌐 stackoverflow.com
Slice() method question
I’m working on a challenge that utilizes .slice() so I’m fooling around with it on Repl.it to get a feel for what it does. I have a question in regard to one particular response that I think I understand but I have a sneaking suspicion that I don’t understand this. More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
November 23, 2018
Confused about the use of slice in javascript - Stack Overflow
I just started learning Javascript. One of the exercises is using slice. My understanding is that slice creates a shallow copy of an array, and that shallow copy, will contain elements from the ori... More on stackoverflow.com
🌐 stackoverflow.com
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › slice
String.prototype.slice() - JavaScript | MDN
The slice() method of String values extracts a section of this string and returns it as a new string, without modifying the original string.
🌐
Medium
windmaomao.medium.com › array-slice-in-javascript-is-super-handy-855237e9538f
Array slice in Javascript is super handy | by Fang Jin | Medium
December 19, 2023 - Javascript isn’t quite flexible when it comes to the parsing and manipulation comparing to other languages such as Python. So I have rely on some comparative ways. If I want to slice the array to take a portion of it, there actually has a built-in function slice for Javascript.
🌐
CoderPad
coderpad.io › blog › development › 4-ways-to-use-javascript-slice-method
4 Ways to Use JavaScript .slice() Method and How to Do Each - CoderPad
April 15, 2026 - ℹ️ Before getting started, we assume that you understand how functions work in JavaScript. If not, check out the JavaScript functions guide to learn more. Put simply, .slice() returns a portion of an array.
🌐
Medium
medium.com › swlh › the-javascript-slice-cheat-sheet-3746c9326bbf
The JavaScript Slice Cheat Sheet
November 13, 2020 - ... “The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array…"
Find elsewhere
Top answer
1 of 9
190

What's happening here is that you call slice() as if it was a function of NodeList using call(). What slice() does in this case is create an empty array, then iterate through the object it's running on (originally an array, now a NodeList) and keep appending the elements of that object to the empty array it created, which is eventually returned. Here's an article on this.

EDIT:

So it starts with an empty array [], then slice is used to convert the result of call to a new array yeah?

That's not right. [].slice returns a function object. A function object has a function call() which calls the function assigning the first parameter of the call() to this; in other words, making the function think that it's being called from the parameter (the NodeList returned by document.querySelectorAll('a')) rather than from an array.

2 of 9
160

In JavaScript, methods of an object can be bound to another object at runtime. In short, javascript allows an object to "borrow" the method of another object:

object1 = {
    name: 'Frank',
    greet() {
        alert(`Hello ${this.name}`);
    }
};

object2 = {
    name: 'Andy'
};

// Note that object2 has no greet method,
// but we may "borrow" from object1:

object1.greet.call(object2); // Will show an alert with 'Hello Andy'

The call and apply methods of function objects (in JavaScript, functions are objects as well) allows you to do this. So, in your code you could say that the NodeList is borrowing an array's slice method. .slice() returns another array as its result, which will become the "converted" array that you can then use.

🌐
Zero To Mastery
zerotomastery.io › blog › javascript-slice
Beginner’s Guide to JavaScript slice() | Zero To Mastery
November 21, 2025 - Want cleaner, easier JavaScript code? Learn how slice() helps you preview items, load more when needed, copy arrays safely, and slice text with confidence.
🌐
daily.dev
daily.dev › home › blog › webdev › js array slice explained
JS Array Slice Explained | daily.dev
May 25, 2026 - The slice() method in JavaScript is a powerful tool for working with arrays. It lets you create a new array by extracting a segment of another array without altering the original.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › ArrayBuffer › slice
ArrayBuffer.prototype.slice() - JavaScript | MDN
July 10, 2025 - The slice() method of ArrayBuffer instances returns a new ArrayBuffer whose contents are a copy of this ArrayBuffer's bytes from start, inclusive, up to end, exclusive. If either start or end is negative, it refers to an index from the end of the array, as opposed to from the beginning.
🌐
Mimo
mimo.org › glossary › javascript › string-slice
JavaScript String slice() Method: Syntax, Usage, and Examples
The JavaScript slice() method is commonly associated with arrays, but it's also a powerful method available on strings. The JavaScript string slice method allows you to extract a portion of a string and return it as a new string, leaving the original string untouched.
🌐
Mimo
mimo.org › glossary › javascript › array-slice
JavaScript Array slice() Method: Syntax, Usage, and Examples
The slice() method returns a shallow copy of a portion of an array into a new array object, selected from a start index to an end index (end not included). The original array remains unchanged. ... Become a full-stack developer. Learn HTML, CSS, JavaScript, and React as well as NodeJS, Express, ...
🌐
Tabnine
tabnine.com › home › how to use the slice method in javascript
How to Use the slice method in JavaScript - Tabnine
July 25, 2024 - The slice() method is a part of both the Array and String prototypes, and can be used with either type of object. The method returns items (from arrays) or characters (from strings) according to the provided indices.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-slice-and-splice-how-to-use-the-slice-and-splice-js-array-methods
How to Use the slice() and splice() JavaScript Array Methods
April 13, 2022 - Unlike the slice() method, the splice() method will change the contents of the original array. The splice() method is used to add or remove elements of an existing array and the return value will be the removed items from the array. If nothing was removed from the array, then the return value will just be an empty array. ... I hope you enjoyed this JavaScript ...
🌐
freeCodeCamp
forum.freecodecamp.org › curriculum help
Slice() method question - Curriculum Help - The freeCodeCamp Forum
November 23, 2018 - I’m working on a challenge that utilizes .slice() so I’m fooling around with it on Repl.it to get a feel for what it does. I have a question in regard to one particular response that I think I understand but I have a sn…
🌐
JavaScript in Plain English
javascript.plainenglish.io › slice-and-splice-methods-in-javascript-17bf4681a16c
Slice and Splice methods in JavaScript | by Jonathan Brierre | JavaScript in Plain English
June 22, 2020 - Slice and Splice methods in JavaScript Today, we’re going over the .slice() and .splice() methods in JavaScript. Both of these methods are quite similar. They both are array and string methods that …
🌐
4Geeks
4geeks.com › en › how-to › javascript-array-slice
How to use the slice method of Arrays in Javascript?
July 16, 2025 - Transform your career with The AI Reskilling Platform. Learn coding, data science, and tech skills with AI tools, real-time feedback, and expert guidance. Join 2,500+ successful learners.