In this case, it is not clear what type is returned in the last line?
What is it, an array of functions?
function Calculator() { var methods = { "-": function(a, b) { return a - b; }, "+": function(a, b) { return a + b; } }; this.calculate = function(str) { var split = str.split(' '), a = +split[0], op = split[1], b = +split[2] if (!methods[op] || isNaN(a) || isNaN(b)) { return NaN; } return methods[op](a, b);