Cześć
Proszę o pomoc - bardziej doświadczonych kolegów
Mam funkcję, ale nie wiem, na jakim poziomie podawać jej argumenty:
Wariant 1
function findModules() {
var
m = {}, patt = /1\s(?:kg|l)\s[-–]\s\d+,\d{2}\szł/;
m.supp = [];
m.unsupp = [];
function mRecord (id, price, desc, weight, unitPrice) {
return { id: id, price: price, desc: desc, weight: weight, unitPrice: unitPrice};
}
function addModule (set, obj) {
set.push(mRecord (obj.id, obj.price, obj.desc, extractWeight(obj.desc), extractUnitPrice(obj.desc)));
}
function handleModul (obj) {
if (patt.test(obj.desc))
addModule(m.supp, obj); //ta linijka ulegnie zmianie
else
addModule(m.unsupp, obj); //ta linijka ulegnie zmianie
}
forEach(retrieveModules(), handleModul);
return m;
}
Wariant 2
function findModules() {
var
m = {}, patt = /1\s(?:kg|l)\s[-–]\s\d+,\d{2}\szł/;
m.supp = [];
m.unsupp = [];
function mRecord (id, price, description, weight, unitPrice) {
return { id: id, price: price, desc: description, weight: weight, unitPrice: unitPrice};
}
function addModule (set, id, price, description, weight, unitPrice) {
set.push(mRecord (id, price, description, weight, unitPrice));
}
function handleModul (obj) {
if (patt.test(obj.desc))
addModule(m.supp, obj.id, obj.price, obj.desc, extractWeight(obj.desc), extractUnitPrice(obj.desc)); // ta linijka uległa zmianie
else
addModule(m.unsupp, obj.id, obj.price, obj.desc, extractWeight(obj.desc)); // ta linijka uległa zmianie
}
forEach(retrieveModules(), handleModul);
return m;
}
Czy to nie ma znaczenia, czy też ma i dlaczego?
Niestety z braku doświadczenia nie umiem tego ocenić :(