Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4014864
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:32:55+00:00 2026-05-20T09:32:55+00:00

I was just browsing Sizzle’s source code and I came across this line of

  • 0

I was just browsing Sizzle’s source code and I came across this line of code:

array = Array.prototype.slice.call( array, 0 );

I looked up what the function is, but I came to the conclusion that it just returns all elements of the array starting from index 0, and puts the whole into the array, i.e. it doesn’t really do anything at all.

What is therefore the use of this line of code? What am I missing?

Edit: It’s line 863 from https://github.com/jquery/sizzle/blob/master/sizzle.js#L863.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:32:56+00:00Added an answer on May 20, 2026 at 9:32 am

    The DOM usually returns a NodeList for most operations like getElementsByTagName.

    Although a NodeList almost feels like an array, it is not. It has a length property like an array does, and a method item(index) to access an object at the given index (also accessible with the [index] notation), but that’s where the similarity ends.

    So to be able to use the wonderful array methods without rewriting them all for a NodeList, the above line is useful.

    Another use of converting it to an array is to make the list static. NodeLists are usually live, meaning that if document changes occur, the NodeList object is automatically updated. That could cause problems, if a jQuery object returned to you kept changing right under your nose. Try the following snippet to test the liveness of NodeLists.

    var p = document.getElementsByTagName('p');
    console.log(p.length); // 2
    document.body.appendChild(document.createElement('p'));
    // length of p changes as document was modified
    console.log(p.length); // 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just browsing the perldocs when I came across this in an example
I was just browsing and came across this question: Action vs delegate event The
While browsing the code of an erlang application, I came across an interesting design
I was browsing a GNUstep project on github and came across this little loop...
I was just browsing some questions when I stumbled upon this one . I
I was just browsing through some of my own code in Telerik's JustDecompile and
I've just been browsing a file in reflector and seen this in a struct
I already have the code of the mp3/wma audio playing/stopping and browsing. I just
I was just browsing through gcc source files. In gcc.c , I found something
I'm browsing through the Android source, just kind of reading it, and I've come

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.