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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:58:54+00:00 2026-06-10T12:58:54+00:00

I find myself using jQuery objects with regular js objects often; I’m trying to

  • 0

I find myself using jQuery objects with regular js objects often; I’m trying to figure out how I can utilize .call and .apply more often in my scripts when appropriate. I’ve been testing code to see how it actually works.

However when I run my code below (which essentially just hides all the divs on the page) in firebug on sites I know have jQuery I get varied results; I’m wondering if it’s the version of jQuery or is this code just ‘buggy’ I am to decipher why .call always works but .apply doesn’t thought it would be the other way around based on code below

var myApp = {} // instantiate an empty objct
myApp.hide = function (whatever) {
   that = whatever
   $(that).hide()
}
var Numbers = function (object) {
this.object = object;
}

Numbers.prototype.div = $('div');
var numbers = new Numbers();
numbers.div
myApp.hide.call(numbers, numbers.div)
myApp.hide.apply(numbers, numbers.div)

When I firebug the code above either using .call or .apply I get different result depending upon the site. Every site that has jquery .call will work but for some sites like jQuery.com and twitter both will work using .apply and .call but other sites like New York Times and Netflix only .call works – I’m guessing it’s the version of jQuery that’s causing the difference but am slightly confused because numbers.div always returns an array of all div elements on the page so I would think that would work all the time. Any explanation is appreciated as I am still grasping the concepts of .call and .apply – I always reference Douglas Crockford’s book but truthfully he doesn’t go into much detail about .apply and .call

  • 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-06-10T12:58:56+00:00Added an answer on June 10, 2026 at 12:58 pm

    .apply need you to pass the arguments as an array.

    SO

    myApp.hide.call(numbers, numbers.div)
    

    should be same as

    myApp.hide.apply(numbers, [numbers.div])
    

    But, in your myApp.hide function, there is no this, so the first parameter of .call or .apply can be anything else, it doesn’t matter.

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

Sidebar

Related Questions

I find myself using the current pattern quite often in my code nowadays var
Very often, I find myself using a callback function and I don't have its
My PHP code is split between many files, and often I find myself using
I often find myself using several programming languages when making .NET applications. Usually C++/CLI
I find myself using the 'pattern' below rather unsettlingly often, when I want to
I'm using jQuery 1.4.4 and I'm trying to find a plugin that will warn
I often find myself using Integers to represent values in different spaces. For example...
I find myself using Resharper's convert to auto property refactoring a lot to remove
I find myself using this method a ton to perform actions based on a
I find myself using hash arguments to constructors quite a bit, especially when writing

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.