Last active
December 19, 2018 08:14
-
-
Save ohcrfpv/8c1d991807c24a67540e7c5e0a361327 to your computer and use it in GitHub Desktop.
三目运算符避免不正确的数据
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = { | |
a: { | |
b: '' | |
}, | |
d: '0', | |
dct: { | |
'0': 'aaaa', | |
'1': 'bbbb' | |
} | |
} | |
var b = data.a? data.a.b: ''; | |
var dFormat = data.dct? data.dct[data.d]: ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment