javascript - How to write this line better in JS -
im having simple if statment , want verify returns having default value, if yes put on variable,for me little bit ugly(to use statement twice), there shorter/nicer way write in js?
if (this._oin._mmet[sm].returns.defval) { var defvalue = this._oin._mmet[sm].returns.defval;
it doesn't make sense me. if value undefined should define variable so:
if(typeof === 'undefined') var = 'something';
but in case value testing if exists define variable, doesn't make sense. so, use variable there:
var defvalue = this._oin._mmet[sm].returns.defval;
you may check if not use if not defined so:
var defvalue = this._oin._mmet[sm].returns.defval || 'undefined';
Comments
Post a Comment