top of page

What does $ mean in JavaScript

In JavaScript, the $ symbol is often used as a shorthand or alias for accessing certain libraries or functions. It is not a special character in the language itself, but rather a convention used by developers.

Two common examples where $ is used in this manner are.

​

jQuery: $ is an alias for the jQuery library. When you see code like $(selector), it is using the jQuery function to select and manipulate HTML elements based on the given CSS selector. Let's look at an example:

Template literals: In ES6 (ECMAScript 2015), JavaScript introduced template literals, which allow you to embed expressions within string literals. The ${expression} syntax is used to evaluate and insert the value of an expression within the string. Again, let's look at an example:

js-stranger.png

Remember that the $ symbol doesn't have any special meaning in JavaScript by itself. Its meaning comes from the context in which it is used and the libraries or conventions being followed.

©2022 - 2024 by JavaScript Schools.

bottom of page