You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DESCRIPTION
Using only string values in placeholders is recommended as otherwise, the value may be wrongly displayed; for example, if an object value is directly included in a string, it will be shown as [object Object]. Using only string values can also ensure that null or undefined values are not directly displayed.
With template literals, an expression can be embedded in a placeholder. A placeholder is represented by ${}, with anything within the curly brackets treated as JavaScript and anything outside the brackets treated as a string.
DESCRIPTION
Using only string values in placeholders is recommended as otherwise, the value may be wrongly displayed; for example, if an object value is directly included in a string, it will be shown as [object Object]. Using only string values can also ensure that null or undefined values are not directly displayed.
With template literals, an expression can be embedded in a placeholder. A placeholder is represented by ${}, with anything within the curly brackets treated as JavaScript and anything outside the brackets treated as a string.
Examples
Bad Practice
const arg1 = [1, 2];
const msg1 =
arg1 = ${arg1}
;const arg2 = { name: 'Cryptosweden' };
const msg2 =
arg2 = ${arg2 || null}
;Recommended
const arg = 'Cryptosweden';
const msg1 =
arg = ${arg}
;const msg2 =
arg = ${arg || 'default'}
;const stringWithKindProp: string & { _kind?: 'MyString' } = 'DeepSource';
const msg3 =
stringWithKindProp = ${stringWithKindProp}
;The text was updated successfully, but these errors were encountered: