Template Literals ` `

No alt text provided for this image

With in the (backticks) ` ` the syntax is called template literals . we can embed expression in string with the placeholder by using $ (sign) and curly_brackets {} like this ${} between curly_brackets, we can add variable name or constant like this {person}. Template literals officially added in ES2015 .

old Syntax

let number = 6

console.log( "Type of " + number + " is integer " )

new syntax

let number = 6

console.log( `Type of ${number} is integer` )

要查看或添加评论,请登录

Muhammad Ahmad的更多文章

  • Add method to array globally

    Add method to array globally

    Add method to array is very straight forward but we need first to clear the core concepts to get it done. we must know…

  • IIFE

    IIFE

    Sometimes we want to run the function only once and never run it again. in this situation (IFFE) Immediately Invoked…

  • Nullish Coalescing

    Nullish Coalescing

    Nullish Coalescing operator was introduced in ES6 2020. this operator is used with the double question mark ?? it only…

    2 条评论

社区洞察

其他会员也浏览了