Skip to content

HW3 accessing arguments of the function #31

@levbrie

Description

@levbrie

@cz2246 asked: How do we access arguments of the function passed as argument. For example in:

var injectedFunc = app.inject(function (Auth, User, MainCtrl, sum) {
return [Auth(), User(), MainCtrl(), sum(1, 2)].join(', ');
});

How can we access the names of the argumnets?

My response:

@cz2246 In this case, the first parameter to inject is a function. All functions have a toString() method that essentially converts the function into its source code version as a string. You then have to parse using a regular expression to get all of the parameters that are passed into that function. Make sense?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions