1

Consider the following code:

<script>
  alert`1` // outputs 1
</script>

or

<script>
  function f($a) {
    alert($a);
  }

  f`2`; // outputs 2
</script>

Why does JavaScript allow functions to be called using `` instead of ()?

References like https://www.w3schools.com/jsref/jsref_operators.asp mentions nothing about the use of ``.

Can `` also be used to call functions that take more than 1 argument? If so, how?

Shuzheng
  • 11,288
  • 20
  • 88
  • 186
  • 3
    it's part of [template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates) that introduced backtick operator – skyboyer Nov 18 '18 at 10:52

0 Answers0