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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:19:04+00:00 2026-05-27T02:19:04+00:00

Possible Duplicate: Inspect the names/values of arguments in the definition/execution of a JavaScript function

  • 0

Possible Duplicate:
Inspect the names/values of arguments in the definition/execution of a JavaScript function

When debugging javascript, I often have code like this:

function doSomething(a,b,c) {
    console.log(a,b,c);

    //function contents here
    //...
}

This results in a line in the console like this:

0.0010719847172334315 0.002392010391772366 -2.764548758273147e-7

Which is hard to read. I want to have output like this:

a: 0.0010719847172334315, b: 0.002392010391772366, c: -2.764548758273147e-7

Is this possible to do? I don’t think it is possible to do in many languages. However, I don’t know javascript very well, and it seems like a language where it is possible to do clever things like this.

  • 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-27T02:19:05+00:00Added an answer on May 27, 2026 at 2:19 am

    You can do something like this by taking in a parameter object and iterating over it:

    function doSomething(options) {
        var i, parameterString = [];
        for (i in options) {
            if (!options.hasOwnProperty(i)) continue;
            parameterString.push(i + ': ' + options[i]);
        }
        console.log(parameterString.join(', '));
    
        //function contents here
        //...
    }
    
    // Invoke like this:
    var result = doSomething({a: 'a', b: 'b', c: 'c'});
    

    Note that most of the cruft is due to you wanting to log the parameters on one line; in some other cases (such as logging one per line), you can simply call console.log on each of the individual strings and not bother with the array or the string join.

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

Sidebar

Related Questions

Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: How to call a JavaScript function from PHP? I have a php
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} What's the
Possible Duplicate: What is the difference between a function expression vs declaration in JavaScript?
Possible Duplicate: Debugging JavaScript in IE7 Firefox has Web Developer plugin and Firebug for
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: Inspect attached event handlers for any DOM element Is there a tool
Possible Duplicate: Parsing text in C Say I have written to a text file
Possible Duplicate: Multiple forms on ASP.NET page i have a doubt. can we place
Possible Duplicate: regex for URL including query string I have a text or message.

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.