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

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -