Method 1: How to Use the “$” Sign as an Identifier?
Create a variable that acts as an identifier:
Pass the identifier to the console.log() method that will identify the stored value in a variable:
Method 2: How to Use the “$” Sign as a Shortcut of Function?
Here’s an example of how you can use the $ sign as a shortcut for a function.
Define a function for adding numbers named “add”:
Assign the add() function to a “$” variable, which means that the “$” variable is now a reference to the add function:
Call the add() function using “$()” by passing values:
You can also use the “$” sign as the function name itself.
Note that using the $ sign as a function name or a variable name is not a good practice because it can be confusing and may cause conflicts with other libraries or code that use the $ sign in a different way.
Method 3: How to Use the “$” Sign in Template Literals?
Create two variables “x” and “y” with values “5” and “11”, respectively:
Store the product of x and y in variable “z”:
Print the result using template literals: