Home >Web Front-end >JS Tutorial >JavaScript partial functions
Use closures to create functions with pre-filled certain parameters.
Javascript code
function jionWords(a, b){ return [a, b].jion(' '); } function prefixer(word){ return function(b){ return jionWords(word, b); } } var hate = prefixer('Hate'); hate('Java'); //返回值为:Hate Java
It can be seen that you can use this to create a function with a dynamic name. It should look awesome and the code will be more readable.