3 ms·
Not a great counterexample imo: function make_dot_product(dim) { return (dim === 3) ? dot3 : dot2; function dot3(a,b) { ret
by jonahx 13y ago
Not a great counterexample imo:
function make_dot_product(dim) {
return (dim === 3) ? dot3 : dot2;
function dot3(a,b) {
return a.x*b.x+a.y*b.y+a.z*b.z
}
function dot2(a,b) {
return a.x*b.x+a.y*b.y
}
}
- Cthulhu_ 13y agoI think I prefer this one, although I'd put the return at the bottom for convention's sake. A lot of people don't know - or want or need to know - about the specifics of hoisting and what-have-you, and will consider this counter-intuitive.