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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:15:21+00:00 2026-05-14T15:15:21+00:00

I was just curious if I could pass a function as a variable. For

  • 0

I was just curious if I could pass a function as a variable. For example:
I have a function

$('#validate').makeFloat({x:671,y:70,limitY:700});

I would like to do something like this:

$('#validate').makeFloat({x:function(){ return $("#tabs").offset().left+$("#tabs").width();},y:70,limitY:700});

This does not work, but ideally every time the variable was accessed it would compute the new value. So if the window was resized it would automatically adjust as opposed to a variable passed in being static. I realize I can implement this directly inside the function\widget, but I was wondering if there was some way to do something like the above.

The concept of this is independent of the plugin. I am talking about the function being “cast” as a variable.

  • 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-14T15:15:21+00:00Added an answer on May 14, 2026 at 3:15 pm

    Yes, you can pass an object which will invoke some function when its property is read (this is called a getter), but it is not cross-browser compatible. For example, this will (probably) work in IE9:

    var o = {y:70, limitY:700};
    Object.defineProperty(o, 'x', {get: function() {return 671;}});
    $('#validate').makeFloat(o);
    

    There are other syntaxes for other browsers such as __defineGetter__ for Firefox, and some browsers don’t have this functionality at all. So it is practically useless unless you can fully control the environment where your code runs.

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

Sidebar

Related Questions

Hi all I was just curious if I could do something like - insert
So I'm just learning Forth and was curious if anyone could help me understand
Just curious, is there a format string I can use to output something like
Just curious if I'm creating a shared memory array on Windows platform like so:
Just curious if it is syntactically possible to do something like this: static (void)
Just curious what is the best practice for solving the following issue. I have
Just curious. How does actually the function Sleep() work (declared in windows.h)? Maybe not
Just curious how you would comment this line of code: string customerNm = customerNm.EndsWith(s)
i was just curious about webbot project and i wish that i could create
Just curious. My thought is that generated files have negligible overhead in terms of

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.