내가있어 const
유성 포함에 color
와 text
변수 :
const exampleTemplate = (text, color) => ('
Hello, this is your text:
${text}.
I hope you liked it. And here comes your color:
<span style="color: ${color}">Boom, here she is.</span>
');
const defaultColor = '#123456';
const firstColor = '#876543';
const secondColor = '#295736';
return exampleTemplate('I am a text example', defaultColor);
defaultColor
다른 변수가 설정되지 않은 경우 어떻게 기본값으로 정의 할 수 있습니까? 이 스레드를 찾았 지만 마크 업을 채택 할 수 없습니다. 내가 사용하려는 defaultColor
CONST는 경우 color
입니다 null
, false
, 0
, NaN
또는 ""
.
기본 매개 변수를 찾고 있습니다.
const exampleTemplate = (text, color = defaultColor) => ('
');
그래도 언급 한 모든 조건에 대해 유형 검사를 수행해야합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다