다음과 같이 배열을 반복하고 싶습니다.
let firstnameList = ["Jan", "Mark", "Doe"];
for (let firstName of firstnameList) {
//In here you can access the current first name by using the newly created variable firstName
console.log('Hello ' + firstName);
// Or
console.log(`Hello ${firstName}`);
}
이것이 새로운 경우 문자열 연결 및 템플릿 리터럴을 확인하십시오.
메시지에서 {firstname}과 같은 자리 표시자를 바꾸려면 다음을 사용할 수 있습니다.
let message = 'This is {firstname} and I am hungry.'
function fillPlaceHolders(rawString) {
return rawString.replace('{firstname}', 'my replace string');
}
console.log(fillPlaceHolders(message));
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다