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
xifxis string, otherwise returns''(empty string) ifxisnullorundefined, otherwise returnsJSON.stringify(x). This is very useful to show a value inside a React component.