1

I have noticed a syntactically strange function/operator in Polymer 3, where the code html`<br/>`, at first look, seems to be typo, but when it's played, it works ...

initial

My guess tells me that it might go into the realm of a new JavaScript shorthand or some other arrow brother, but I haven't figure it out/discovered it yet.

The debugger shows that it's a function:

Debugger

However when I want to step into it shows me just a comment.

Debugger goes wild

What is this strange thing? And how can one define it?

Tiberiu C.
  • 3,365
  • 1
  • 30
  • 38
  • 3
    It's a feature of template literals called "tagged template literals". See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals for the details. – Mike 'Pomax' Kamermans Jul 30 '18 at 22:00
  • On what criteria is decided that it a duplicate? software development? In that regard, all the questions on SO can be a duplicate. – Tiberiu C. Jul 30 '18 at 22:14
  • Look at the top of your post, which now has a banner telling you which question this was a duplicate of. Although that said, the people who closed it seemed to have ignored the fact that your question wasn't about what the backticks were, but what the tagged use of them was (which, to be fair, almost _no one_ uses, and not a lot of folks know about. @charlietfl, this seemed a perfectly fine question to me) – Mike 'Pomax' Kamermans Jul 30 '18 at 22:19
  • @TiberiuC. See [help](https://stackoverflow.com/help/duplicates) on duplicates. – tony19 Jul 30 '18 at 22:21
  • At first glamce ... 'help on duplicates' doesn't cover a question that is a subtopic of another question. – Tiberiu C. Jul 30 '18 at 22:36
  • Anyway, Thanks Mike! – Tiberiu C. Jul 30 '18 at 22:40
  • The help I linked directly answers [your question](https://stackoverflow.com/questions/51602850/what-is-the-name-of-the-operator-with-the-form-dosomethingh1-in-javascript#comment90171934_51602850) on how duplicates are determined on SO and the steps you can take if you think your question is not a duplicate. – tony19 Jul 30 '18 at 22:47
  • @Mike The linked duplicate question actually has an [answer](https://stackoverflow.com/a/40062505/6277151) that addresses tagged template literals as a usage of backticks, so I think this question was correctly closed. – tony19 Jul 30 '18 at 22:50
  • An answer that answers the question and then provides even more information is an excellent answer, but does not make different questions that happened to be covered by that answer duplicates of the original question. People search for questions on SO, and people searching for what backtick strings immediately following what seems like a variable name mean will see a question labeled "what is the usage of the backtick" and go "no, I know what those do already, my question is more specific", then skip over it looking for a question that matches theirs. – Mike 'Pomax' Kamermans Jul 30 '18 at 22:54

0 Answers0