I have an if
statement :
if (argList["foo"] === "bar" || argList === "bar"){
// some code
}
I am curious if there is a concise or more elegant way to express this condition.
The reason behind writing this statement is that I have two functions: startTool(argList) and startCreate(argList).
mod.zsh_apiStartTool = function(argList, callback) {
// some code
if (argList["tool"] === "measure" || argList === "measure"){
//some code to start the tool
}
if (argList["tool"] === "scanning"|| argList === "scanning"){
// some code to start the tool
}
ZSH_JS_API_ERROR(callback);
return;
}
mod.zsh_apiStartCreate = function(argList, callback) {
// some code
if (argList["tool"] === "measure"){
mod.zsh_apiStartTool("measure")
}
if (argList["tool"] === "scanning"){
mod.zsh_apiStartTool("scanning");
}
ZSH_JS_API_ERROR(callback);
return;
}
Hence, when I call startTool from startCreate, my variable will not be argList["foo"] === "bar" but rather argList === "bar"