Say I have a simple object created by from user input:
var input = { url: 'http://example.com/', path: 'abc', user: 'adam' };
And I am to write function(s) that update url and path properties according to some business logic, there are many approaches:
A. functional
input.url = validate(input);
input.path = convert(input);
B. side-effect
update(input);
C. create a new object internally
input = process(input);
For javascript, is it always better to use the functional approach, for easier debug and speed? Or a general thought process on deciding which is more appropriate.
Aucun commentaire:
Enregistrer un commentaire