Search⌘ K
AI Features

Functions in Javascript

Explore advanced JavaScript functions by practicing passing arrays as arguments, using closures, creating partial functions, and manipulating the context and arguments object. This lesson helps you build deeper understanding and application of JavaScript functions.

We'll cover the following...

Assess your skills

Test yourself by using an array as an argument when calling a function.

Javascript (babel-node)
// Return what fn returns using arr as arguments
argsAsArray = function(fn, arr) {
}

Test yourself by changing the context in which a function is called.

Javascript (babel-node)
// Return what fn returns with obj as its context
speak = function(fn, obj) {
}

Test yourself by returning a function from a function.

Javascript (babel-node)
// Return a function that takes an argument
// and concats 'str' and the argument
functionFunction = function(str) {
}

Evaluate yourself by implementing the closures.

Javascript (babel-node)
// Return an array of closures calling fn on array items
makeClosures = function(arr, fn) {
}

Evaluate yourself by creating a partial function.

Javascript (babel-node)
// Return a function that takes one arg
// and return the result of fn with str1,
// str2 and arg.
partial = function(fn, str1, str2) {
}

Test yourself by using the arguments object.

Javascript (babel-node)
// Returns sum of all arguments
sumArguments = function() {
}

Test yourself by applying functions with arbitrary numbers of arguments.

Javascript (babel-node)
// Call fn with all the arguments
// and return results
callIt = function(fn) {
}

Test yourself by creating a partial function for a variable number of applied arguments.

Javascript (babel-node)
// Returns a function that takes calls
// fn with all the arguments passed to this function
// and to the function that's returned.
partialUsingArguments = function(fn) {
}