Yeah I know, title is confusing. So here is the example :var _ = require("lodash");var flag = _.get(req, 'data.flag') || _.get(req, 'config.flag') || 9;My req object has a data key which can have 0,1,2 as values. Same for config. So if in my request object, data.flag is undefined, I check for config.flag and if that's undefined too I put 9 as value in the flag. The problem is when data.flag=0 I need to set 0 in the flag but JS will take 0 as false and it will check in config.flag. Basically, if my data.flag is 0, I need to save 0 in flag variable. So how do I overcome this in efficient way?
Submitted November 06, 2019 at 12:19PM by GhostFoxGod
No comments:
Post a Comment