Your two most recent questions were closed as off-topic. Specifically, they were judged to be generic/hypothetical code rather than real code.
In Best practicing for passing an object as parameters to a function…
} else if (options.canGetDefault && options.type === 'xxx') {
if (item.xxx.is_default === true) {
result = item;
}
}
… the likely trigger were the xxx
placeholders. What do you mean by them? For that matter, _data
is vague too, and we don't really know the context in which you would call _find(options)
.
In Implementing Command Pattern - How to make more readable if else statements for commands?…
var cmdP = {
_unexecuted: [],
_executed: [],
execute: function (cmd) {
this._unexecuted.length = 0; // common
//---------------------------------- check type
if (cmd.declaredClass === 'a') {
alert('logic change cmd for type a');
} else if (cmd.declaredClass === 'b') {
alert('logic change cmd for type b');
}
//----------------------------------
cmd.execute(); // common
this._executed.push(cmd); // common
}
}
var cmd = {
declaredClass: 'b',
execute:function(){
alert('cmd executed')
}
};
cmdP.execute(cmd);
… "execute some operations on a passed object" is a generic problem, and 'a'
and 'b'
are hypothetical names. In addition, the alert()
calls are placeholders.
Please read Why is hypothetical example code off-topic for Code Review? to understand why these decontextualized questions are problematic. You may think that you are being helpful by stripping out irrelevant detail. However, these modifications make it impossible to write a good review. We can't tell which parts of your code are literal and which parts are hypothetical. There is also a chance that you've stripped out very relevant information that would have allowed us to give you better advice.
For these reasons, Code Review deals only in concrete code. Please give us the straight, unadulterated version of your code so that we can review it properly.