javascript - Property name same as non anonymous function -
i'd use non anonymous functions better debugging purpose , encountered following question.
when have function returning object of methods (like in angularjs factories), bad style name returned property , function same?
like here:
angular .module('mymodule', []) .factory('foobar', foobar); function foobar() { return { foo: function foo() {console.log('foo')}, //is ok bar: function barfunc() {console.log('bar')} //or way better } }
this not question of style, , doesn't have definitive answer. there surely nothing wrong naming function expression same property.
however, aiming better debugging experience. should ask yourself: "what name helps me best identify function in code name?". whether might foo
, foofunc
, foobar_foo
(including module name) or else, have decide yourself.
Comments
Post a Comment