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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:02:57+00:00 2026-05-23T04:02:57+00:00

In JavaScript, I wonder why I can do this: [].slice.apply([1,2,3], [0, 2]) // returns

  • 0

In JavaScript, I wonder why I can do this:

[].slice.apply([1,2,3], [0, 2]) // returns [1, 2]

Which is as far as I understand equivalent of this:

Array.prototype.slice.apply([1,2,3], [0, 2]); // returns [1, 2]

But I can’t do this:

{}.hasOwnProperty.apply(a, ['a']);

Which would allow to not type this long line:

Object.prototype.hasOwnProperty.apply(a, ['a']); // returns true or false

Well, while I am at it, I also see that I can actually do all of these:

''.indexOf.apply('asdasd', ['s']); // returns 1
true.toString.apply(true); // returns // "true" as string

What the deal with {} ? 🙂 Why is it special?

  • 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-23T04:02:58+00:00Added an answer on May 23, 2026 at 4:02 am

    Is hasOwnProperty('a') a typo?

    {}.hasOwnProperty.apply(a, ['a']);
    

    But that doesn’t quite work due to JavaScript interpreting {} as block delimiters. Just add parentheses:

    ({}).hasOwnProperty.apply(a, ['a']);
    

    Check it:

    > var a = {'a': 1}
      Object
    > {}.hasOwnProperty.apply(a, ['a']);
      SyntaxError: Unexpected token .
    > ({}).hasOwnProperty.apply(a, ['a']);
      true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if fancy animations such as this can easily be done using JavaScript
I wonder why I can't get value from FCKEditor with this javascript? I work
I wonder if anyone can work this HTML, CSS, Javascript puzzle out? I'm using
As JavaScript can be disabled in the browser by the user, I wonder if
I just wonder if it is possible to only use CSS but not javascript
I am developing a pet project with Clojure, but wonder if I can speed
I've just discovered the way to create fake 'classes' in javascript, but I wonder
I wonder if someone here can help me figure out this problem. I need
I am trying to understand a third party Javascript code. But am not able
I wonder if there is a way to use ungreedy matching in JavaScript? 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.