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 6856201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:51:19+00:00 2026-05-27T01:51:19+00:00

I was wondering about this piece of code: var numbers, _ref; numbers = [0,

  • 0

I was wondering about this piece of code:

var numbers, _ref;
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

[].splice.apply(numbers, [3, 4].concat(_ref = [-3, -4, -5, -6])), _ref;
alert(numbers);

From here, the result is [0, 1, 2, -3, -4, -5, -6, 7, 8, 9]
and can anyone explain me about this?

  • 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-27T01:51:20+00:00Added an answer on May 27, 2026 at 1:51 am

    function.apply(context, argsArray) calls function in the given context, passing argsArray as the arguments for function.

    In this case, function is [].splice, which takes the following parameters, in this this order:

    1. index – at which to start changing the array
    2. howMany – elements to remove, starting at index
    3. element1,…,elementN – elements to insert into the array at index

    [3,4].concat(_ref = [-3, -4, -5, -6]) evaluates to an array by concatenating the two arrays together, giving [3, 4, -3, -4, -5, -6]. This is the argsArray passed to .apply(), so that:

    1. index == 3 (start at index 3)
    2. howMany == 4 (remove 4 elements)
    3. element1,…,elementN == -3, -4, -5, -6 (the elements to insert at index 3, after removal)

    Thus .apply() is causing the .splice() function to run in the context of the numbers array, removing elements at indices 3, 4, 5 and 6, and then inserting the elements -3, -4, -5 and -6 between “2” and “7” in the original array.

    Edit: See RobG’s answer for a summary of what the original code is equivalent to (rather than an explanation of its parts).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering about this sample piece of code: int main() { char *p ;
I was wondering about something. Lets say I have this piece of code: if
i'm wondering about this possibility. Is it possible to make our code written in
I am wondering about the the following piece of Java code: System.out.println. I am
I have this piece of code: var myObj = function () { this.complex =
I've just replaced this piece of code: foreach( var source in m_sources ) {
I was always wondering about this seemingly utopic world of open source. Assuming the
I been wondering about this for a while. It seems like there are so
I've been wondering about this problem for some time - doubleclicking a winforms TabControl's
I am wondering about the performance of this index: I have an Invalid varchar(1)

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.