2

I have a simple javascript function like this:

function wrapVar (passVar) {
    var option = {
        varValue: passVar,
        hide: true,
        params: { ..otherparams.. }
        };
    return option;
}

Eclipse and Aptana validation says that the local variable 'option' is redundant. But the meaning of "redundancy" in this case is not clear to me, what should i do to avoid it?

2
  • 1
    not sure you should necessarily avoid that. i think its personal preference and also not something that jshint would pick up. Commented Oct 7, 2014 at 17:48
  • Sometimes they hint at redundancy when nothing is wrong with the code itself Commented Oct 7, 2014 at 17:49

1 Answer 1

5

Probably, it means you can use the equivalent

function wrapVar (passVar) {
    return {
        varValue: passVar,
        hide: true,
        params: { ..otherparams.. }
    };
}
Sign up to request clarification or add additional context in comments.

1 Comment

Absolutely true, it was just an optimization tip! the code was already running but i had desire to understand.. Now it's clear, 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.