![]() |
In JavaScript, a dollar ($) sign is not considered a built-in operator or a special symbol. The dollar sign ( $ ) is just another character that can be used in variable names. It is just like any other letter that can be used as the first or subsequent character in a variable name. Table of Content Using $ as an IdentifierThe dollar ($) sign in JavaScript can be used as an identifier which means it can be used to simply identify an object in the same way that a variable or name does. It can be used to identify any variable, function, object, property, or event. Syntax:function $(selector) { Example: The below code implements the $ sign as the name of a function in JavaScript that selects elements. HTML
Output: Using $ in Template literalsThe dollar ($) sign is also used in template literals. This method was introduced recently in the ECMAScript 2015 (also known as ES6 or ECMAScript 6) for a convenient way of string interpolation and multiline strings in JavaScript. The template literals are delimited using backticks (“), instead of single or double quotes. This method allows us to directly use an expression inside a string using placeholders, denoted by – ${expression} Example: The below code explains the use of dollar ($) sign to access the values of variables in template literals. Javascript
Output
Company name: GeeksforGeeks, Description: A Computer Science Portal. |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |