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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:28:13+00:00 2026-06-17T17:28:13+00:00

I have a function which you can pass an object to. I then need

  • 0

I have a function which you can pass an object to. I then need all the vars within this object to become local variables. For instance

function ping(){
    alert(riff); //'raff'
}

ping({
    riff: 'raff'
});

The only way I can think to do it is looping the object and setting them one by one but that seems clunky. Any alternatives?

Edit: the return was to show what that variable would be like. The main thing I don’t want is to have to go through another object to get to the data. I want the structure to be

 function.riff = 'raff' 

rather than

 function.settings.riff = 'raff'
  • 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-17T17:28:14+00:00Added an answer on June 17, 2026 at 5:28 pm
    function ping(){
        for(var key in arguments[0]){
            this[key] = arguments[0][key];
        }
    }
    

    This currently the best answer I can come up with… any advances on this?

    Note how the vars are added directly into the function rather than through an object in the function.

    This is because I want to be able to overwrite private function vars with this object before they are used.

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

Sidebar

Related Questions

Can I´m asking for advice. I have function which should return javascript object function
Hallo, how can I pass more parameters to usort? I have different functions, which
Suppose I have a function which can either take an iterable/iterator or a non-iterable
In C and C++ we have the memset() function which can fulfill my wish.
Do MySQL have any function by which I can split data of a column
I have a function which takes a custom struct as the argument. how can
I have a function which looks something like this, it returns a noncopyable class
I have the need to pass an object from jstl to a Jquery click
On page load, I have my DataTable results available which I need to pass
I have the following query, which returns a single row. MODEL: function get_guide_first(){ $this->db

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.