partial()

by Cristi Salcescu

JavaScript

function log(level, message){
	console.log(level  + " : " + message);
}

Function.prototype.partial = function(...leftArguments){
	let fn = this;
	return function partialFn(...rightArguments){
  		let args = leftArguments.concat(rightArguments);
  		return fn.apply(this, args);
  }
}

let logInfo = log.partial("Info");
logInfo("here is a message");