Beta

Serialize Function Arguments

97 of 98aymanfarhat

Description:

Serializing data in Javascript is a common practice, usually that is done to form values before sending them through a request. But consider this scenario.

Given a function with arguments, we would like to serialize its values and parameters into a string of key/value pairs, while optionally ommiting some keys(parameters).

Example usage:

function someFunction (name, family, position, n_children) {
    data = serializeFunc(someFunction, arguments, ['family', 'n_children']);
    // data's value would be: name=joe&position=developer
    // rest of the function...
}

Implement the serialize function so that it serializes the function's arguments into a string of parameter/argument pairs. Keys being the parameter names and values being the respective argument values.

The function should take three parameters: function, arguments, and optional list of excluded keys.

To make it simple, lets consider that all the values being passed are either string or number.

Fundamentals

Stats:

CreatedFeb 2, 2014
PublishedFeb 2, 2014
Warriors Trained826
Total Skips319
Total Code Submissions839
Total Times Completed98
JavaScript Completions97
Total Stars9
% of votes with a positive feedback rating89% of 38
Total "Very Satisfied" Votes30
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes0
Total Rank Assessments44
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • aymanfarhat Avatar
Ad