Returns x if x is string, otherwise returns '' (empty string) if x is null or undefined, otherwise returns JSON.stringify(x). This is very useful to show a value inside a React component.
x
''
null
undefined
JSON.stringify(x)
Returns
x
ifx
is string, otherwise returns''
(empty string) ifx
isnull
orundefined
, otherwise returnsJSON.stringify(x)
. This is very useful to show a value inside a React component.