首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >`` meaning (`${info}:${pokemondetails[info]}\n`)`是什么意思?

`` meaning (`${info}:${pokemondetails[info]}\n`)`是什么意思?
EN

Stack Overflow用户
提问于 2019-03-24 00:30:20
回答 1查看 37关注 0票数 0

下面的代码中的alert(`${info} : ${pokemondetails[info]}\n`)是什么意思?有人能用更简单的形式给我解释一下吗?

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2019-03-24 00:33:51

代码使用的是Template Literals

模板文字是允许嵌入表达式的字符串文字。您可以对它们使用多行字符串和字符串插值功能

模板文字被用来在字符串中插入表达式( return一个值的东西),而不会有疯狂的语法使用过多的+ signs.The行与

代码语言:javascript
复制
alert(info + " : " + pokemondetails[info] + "\n")
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55315904

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档