Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I return an anonymous object in Javascript? [closed]

Tags:

javascript

I am trying this:

return {
    configs: app.config
}

But it does not seem to work. Is there another way to return an anonymous object with the one field "configs" ?

like image 553
Samantha J T Star Avatar asked Jun 04 '14 02:06

Samantha J T Star


1 Answers

function someFunc() {
    var retVal = {
        configs: app.config
    };
    return retVal;
}

Here is another idea:

var someFunc2 = function() { 
    var app = {};
    app.config = 1;
    return { configs: app.config };
};
someFunc2();
// Object {configs: 1}
like image 197
Jess Avatar answered Oct 23 '22 06:10

Jess