Set the length of a function in JavaScript