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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:38:14+00:00 2026-05-13T17:38:14+00:00

Original source: http://twitter.com/tobeytailor/status/8998006366 (x=[].reverse)() === window // true I’ve noticed that this behavior affects

  • 0

Original source: http://twitter.com/tobeytailor/status/8998006366

(x=[].reverse)() === window // true

I’ve noticed that this behavior affects all the native types. What exactly is happening here?

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

    This is to do with the weird way this binding works in JavaScript.

    [].reverse
    

    is the method reverse on an empty list. If you call it, through one of:

    [].reverse();
    []['reverse']();
    ([].reverse)();
    

    then it executes with this bound to the list instance []. But if you detach it:

    x= [].reverse;
    x();
    

    it executes with no this-binding, so this in the function points to the global (window) object, in one of JavaScript’s worst, most misleading design mistakes.

    (x=[].reverse)()
    

    Is also doing the detach. The assignment operator returns the same function object it was passed so it looks like it’s doing nothing, but it has the side-effect of breaking the limited special case that causes JavaScript to bind this.

    So you are saying:

    Array.prototype.reverse.call(window)
    

    reverse, like many other Array.prototype methods, is defined by ECMAScript to work on any native sequence-like object. It reverses the items with number-string keys (up to object.length) and returns the object. So it’ll return the object that was passed in for any type that has a length property.

    window has a length property, which corresponds to window.frames.length, so calling this method with this pointing at window will work and return the window. In theory it may still fail, because:

    1. window is allowed to be a “host object” rather than a “native object”; in this case the guarantees about what you can pass to other prototypes’ methods don’t necessarily apply; and
    2. if the window actually has frames/iframes, it would try to reverse their order, which wouldn’t work because the frame collection is read-only.

    However, in current browsers the former case does work and the latter fails silently without an error, so you still get the ===window behaviour and not an Exception.

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

Sidebar

Ask A Question

Stats

  • Questions 300k
  • Answers 300k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No. Rebuild it against 2.5.5 instead. May 13, 2026 at 8:03 pm
  • Editorial Team
    Editorial Team added an answer For smaller or personal projects, I would recommend using something… May 13, 2026 at 8:03 pm
  • Editorial Team
    Editorial Team added an answer I think putting it in your base page would be… May 13, 2026 at 8:03 pm

Related Questions

Im using the gem for thinking sphinx: sudo gem install freelancing-god-thinking-sphinx \ --source http://gems.github.com
There are a couple of tricks for getting glass support for .Net forms. I
I'm really suprised I haven't run into this problem before, but it seems that
so I'm using Visual Studio 2005 and for my current project I'm building a
First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.