I have recently taken over someone else's job for programming. I am reading her old script, and seeing an if/ese statement like this:
nlapiLogExecution('ERROR', 'ID', rid);
if (prefstocking && prefstocking >0) {
item.setFieldValue('preferredstocklevel', prefstocking);
shouldshow = 1;
} else {.....
(^^ It keeps going, but this is the important part) Everything in this script makes sense, (it uses special functions from SuiteScript) BUT I'm really confused where she put "prefstocking && prefstocking" Earlier in her script, she created a variable named prefstocking, so that part makes sense. What gets me is she put it on both sides of the logical operators.. but I thought using the logical operator "&&" means to use both of them, like "if x && y = 1" makes sense to me, but using the same value twice ?? Can anyone explain why it would be beneficial to use the same value on both sides of the && logical operator ? (Keep in mind I am relatively new to javascript) Thanks!
Aucun commentaire:
Enregistrer un commentaire