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

The Archive Base Latest Questions

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

Seeing this block from jQuery.scrollTo.js library (in v1.4 at line 184). function animate( callback

  • 0

Seeing this block from jQuery.scrollTo.js library (in v1.4 at line 184).

function animate( callback ){
    $elem.animate( attr, duration, settings.easing, callback && function(){
        callback.call(this, target, settings);
    });
};

Curious to know how the comparison is going to work with

callback && function() {callback.call(...)}; 

and what’s exactly the meaning behind this. Thanks in advance.

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

    The callback && function() {callback.call(...)}; is doing two things:

    • testing whether a callback has been defined and
    • if it has, calling it in the correct context

    JavaScript has a feature called “short-circuiting logical expressions”. If a part of a logical expression cannot change the overall result, it is not going to be evaluated.

    If callback is undefined, then it evaluates to false in the context of a logical expression (it’s “falsy”). So the expression becomes the equivalent of false && ..., in which case it does not matter anymore what ... actually is, the result will always be false †1. JavaScript is not looking at the ... in this case.

    If callback is not undefined (but a function), the first part of the logical expression evaluates to true (it’s “truthy”). At this point JavaScript evaluates the .... The overall result happens to be a function expression. The function expression results in an anonymous function, which is then passed to jQuery’s animate().

    The callback.call() executes callback and determines the meaning of this within callback. So callback.call(this) makes sure that this refers to the same object as in the outer function.


    †1 To be absolutely correct: The overall result of the expression will not be false, it will be undefined.

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

Sidebar

Related Questions

I'm seeing this exception message coming from XslCompiledTransform.Transform(), but after handling the exception the
I've been seeing this instruction as the very first line of numerous CSS files
We're seeing this exception occur in the following block of code in an ASP.NET
I am trying to create a filter in .net to block users from seeing
Seeing this: http://www.suckless.org/wiki.html . A wiki based on Mercurial. Are there any other non-code
I'm seeing this error several times an hour on my production site and am
I am seeing this error intermittently. My app throws PageRequestManager is undefined and so
I remember seeing this on Ajaxian and a couple other sites but I never
I've been seeing this in my Visual C# 2008 RSS Feed forever now: http://lincolnfair.net/oldLincolnFair/mad.jpg
I'm seeing this in the Debugger Console: <Error>: CGImageSourceGetType image source parameter is nil\n

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.