javascript - Using conditionals inside template literals -


i know more elegant way define string variables included, if want add conditional in pre es6 do..

var = "text"+(conditional?a:b)+" more text" 

now template literals do..

   let a;    if(conditional) = `test${a} more text`;    else = `test${b} more text`; 

is there more elegant way implement conditional? possible include if shortcut?

use this:

let = `test${conditional ? : b} more text`; 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -