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

  • SEARCH
  • Home
  • 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 6595281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:55:12+00:00 2026-05-25T17:55:12+00:00

ap = Array.prototype, aps = ap.slice, apsp = ap.splice, I often see code like

  • 0
 ap = Array.prototype,
 aps = ap.slice,
 apsp = ap.splice,

I often see code like above in different frameworks. What are the benefits of this?
Why not use it directly?

  • 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-25T17:55:13+00:00Added an answer on May 25, 2026 at 5:55 pm

    Several benefits:

    1. Faster at run-time (fewer lookups to get the final result)
    2. Smaller code before minification
    3. Easier to reduce even more with minification
    4. Less typing when coding

    One should note that I think it makes the code less readable to people not already familiar with the code or its conventions because the code isn’t as self documenting. Everyone knows what Array.prototype.splice is but strangers don’t know what aps is until they study the code, track down its definition and remember what it is.


    I was asked in a comment to explain the fewer lookups issue:

    For the interpreter to resolve Array.prototype.splice, it has to do the following:

    1. Look in the local scope for the Array name. It doesn’t find it.
    2. Look in any closures (e.g. parent scope) for the Array name. It doesn’t find it.
    3. Look in the global scope for the Array name. It finds it.
    4. On the Array object, look for the prototype property.
    5. On the prototype property, look for the splice property and now it finally has the function it needs.

    For the interpreter to resolve aps, it has to do this:

    1. Look in the local scope for the aps name. It finds it and not it has the function it needs.

    The pre-assignment to aps has essentially pre-done the lookups so that they are already resolved at runtime. This removes some flexibility because if the value of the splice or prototype properties are changed, the variable aps won’t reflect that change, but if you know they aren’t supposed to change (something the run-time interpreter doesn’t know), then you can take advantage of this shortcut.

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

Sidebar

Related Questions

From: http://ejohn.org/apps/learn/#2 Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object =
I copied this code from an example . I've read it 100 times. Array.prototype.map
Array.prototype.clear = function(){ this = new Array(); return true; } That code raise an
Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return
This is Mozilla's Code in Mozilla's Array.prototype.indexOf if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(elt) {
I want to extend Array and Object like the following code: $(window).load(function() { Array.prototype.x
I got this from Paul Irish , window.log = function(){ if(this.console){ console.log( Array.prototype.slice.call(arguments) );
Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return
var shell = function (method) { window[method].apply(null, Array.prototype.slice.call(arguments, 1)); }; shell('alert', 'monkey!');
I need a prototype done in this way: Array.prototype.getname=function(){ [...]return arrayname; } So I

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.