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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:21:11+00:00 2026-06-14T19:21:11+00:00

How does JavaScript function call with prototype function name.argument work in the following program?

  • 0

How does JavaScript function call with prototype function name.argument work in the following program?

 function getLAdd() {
     // this sets all the variables containing positions of ball and bar with their respective ids.
     var ladd = 0;
     var pball = $("#ball");
     var pbar = $("#bar");
     var bar_position = pbar.position();
     var ball_position = pball.position();
     if (ball_position.top >= window.innerHeight - 100) {
         if (ball_position.left - 10 >= bar_position.left && ball_position.left - 10 <= bar_position.left + 100) {
             ladd = -2;
         }
         if (ball_position.left + 10 <= bar_position.left + 200 && ball_position.left + 10 >= bar_position.left + 100) {
             ladd = 2;
         }
     }
// how does getLAdd.ladd work ? Is this a type of dynamic call ?
     if (ladd == 0) {
         ladd = getLAdd.ladd;
     }
     if (ball_position.left <= 15 || ball_position.left >= window.innerWidth - 40) 
         ladd = -ladd;

     getLAdd.ladd = ladd;
     return ladd;
 }
  • 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-14T19:21:13+00:00Added an answer on June 14, 2026 at 7:21 pm

    Functions in JavaScript are objects, so you can add properties to them.

    In this code a property named ladd has been added to the getLAdd function, and is being retrieved on this line:

    ladd = getLAdd.ladd;
    

    and is being updated on this line:

    getLAdd.ladd = ladd;
    

    You can do the same thing with any function.

    function f() {
           // get the property
        console.log(f.foo); // bar
    }
    
       // add a property to the function object
    f.foo = "bar";
    
       // get the property
    console.log(f.foo); // bar
    
       // call the function
    f();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody explain to me what this does in javascript? (function (x,y){}(x,y)); or this
How does the Function Scope in JavaScript work?
I'm actively learning javascript, and I came across the following statement: Object.prototype.toString.call([]); And I
Why does the Javascript function call isNaN(123.) return false? (notice the dot (.) after
I have a javascript function: string.prototype.startsWith = function(str) { return (this.indexOf(str) === 0); }
Possible Duplicate: IE only javascript error with getElementsByTagName var rows=myTable.getElementsByTagName('tr'); rows=Array.prototype.slice.call(rows,0); Does not work
I have a question on 'call' in javascript. var humanWithHand = function(){ this.raiseHand =
I doubt about the call function in Javascript. I have this jQuery plugin: (function($)
does anybody know how to call C++ functions or methods via JavaScript. Need scripting
What does the below JavaScript mean? Why is the function embedded inside ()? (function()

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.