1
function log(tobelogged){
    if (debugging){
        c.log(arguments);
        c.log(arguments.toString());
        c.log(tobelogged);
    };
};

and then

log(someObject);

and I want to response

'someObject'
'whatever is in someObject'

I tried toString() above but clearly I'm missing something. How do you get the 'name' of what's sent to the function? The example uses oni apollo stratified sjs in the browser but I don't think it matters here. Anyy ideas?

2 Answers 2

4

An argument doesn't have a name. It only has a reference via a parameter, or via an index of the arguments object. The parameter name is an indirect reference from the parameter to an index in the arguments object.

In strict mode, there's even less of a correlation, since you can modify the values of the parameters without affecting the value of the arguments object, and vice versa.

I think the closest you'll come is using...

console.dir( arguments ); // instead of console.log 

...which should give you an expandable object, so you can see the arguments by index.

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

As you say, doesn't do what I wanted though.
1

That information is lost and not available in arguments.

You could set a break point there (throw in debugger;) and examine the call stack.

1 Comment

You're right, there's no shorthand way to do what I want. Though I'm not how to use the debugger command, reading.. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.