以下代码中alert(`${info} : ${pokemondetails[info]}n`)
的含义是什么?有人可以用更简单的形式向我解释吗?
let checkname = function(findname,findpokemongame)
{
for(let thispokemon in findpokemongame.pokemon)
{
if(findpokemongame.pokemon[thispokemon].name == findname)
{
let pokemondetails = findpokemongame.pokemon[thispokemon];
for(info in pokemondetails)
{
alert (`${info} : ${pokemondetails[info]}n`); //explain this part in simple form
}
}
}
}
checkname(findname, findpokemongame)
代码正在使用模板文本。
模板文本是允许嵌入表达式的字符串文本。您可以将多行字符串和字符串插值功能与它们一起使用
模板文字用于在字符串中插入表达式(return
值的东西(,而不会使用太多+
符号进行疯狂的 synatx。该行与
alert(info + " : " + pokemondetails[info] + "n")