下面的代码中的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)发布于 2019-03-24 00:33:51
代码使用的是Template Literals。
模板文字是允许嵌入表达式的字符串文字。您可以对它们使用多行字符串和字符串插值功能
模板文字被用来在字符串中插入表达式( return一个值的东西),而不会有疯狂的语法使用过多的+ signs.The行与
alert(info + " : " + pokemondetails[info] + "\n")https://stackoverflow.com/questions/55315904
复制相似问题