What Does $ Mean in JavaScript?
In JavaScript,
$has no universal meaning: its surrounding syntax determines whether it is an identifier, a function name, a template substitution marker, a regular-expression assertion, or part of a replacement token.
The Short Answer: $ Depends on Its Context
Start by looking at the characters around it:
| Appearance | Context | Meaning |
|---|---|---|
$ or $total | A declaration or expression | An identifier, which is a name |
$(value) | A call expression | Call the value stored under the name $ |
`${value}` | Inside backticks | Evaluate value and insert its result |
/$/ | Inside a regular-expression pattern | Assert the end of the input |
"$&" or "$1" | The replacement argument of replace() | Insert matched text or a captured group |
These forms happen to share one character. They do not share one mechanism.
$ determine which meaning JavaScript uses.An identifier names a variable, function, parameter, or another binding. An operator such as + performs an operation. An expression is code that produces a value, such as price + tax. Parentheses, backticks, slashes, braces, and quotes provide the punctuation that tells JavaScript how to parse the characters between them.
That surrounding syntax is the decoder. Without it, asking what $ means is like asking what a parenthesis means without seeing the line that contains it.
The dollar sign is also unrelated to JavaScript’s Symbol primitive. $ is a character you can use in source code; Symbol is a value type.
$ Is a Valid JavaScript Identifier
An identifier is a name JavaScript uses to refer to something. The language permits the U+0024 DOLLAR SIGN character anywhere in an identifier name, so $, $total, and total$ are all legal names.
Here are all three forms in one complete example:
const $ = 3;
const $total = 12;
const total$ = 4;
console.log($);
console.log($total);
console.log(total$);
3
12
4
The first declaration creates a variable whose entire name is $. The second starts its name with a dollar sign, and the third ends its name with one. Each name refers to an ordinary number.
Nothing about $total makes the value reactive, private, monetary, or connected to a library. A project may adopt one of those conventions, but the meaning then comes from that project.
The same rule applies to function names:
function $(amount) {
return amount * 2;
}
console.log($(6));
12
Here $ names a function. Writing $ by itself retrieves that function value, while $(6) calls it with the argument 6. The function doubles the number because its body says so, not because its name contains $.
This distinction separates language syntax from naming convention. JavaScript decides that $ is allowed in the name. The declaration decides which value the name holds. Your code, a library, or an imported module decides what that value does.
Identifiers are resolved through scope, so two parts of a program can use the same spelling for different bindings. Variable scope and closure explains how JavaScript chooses the accessible binding when names repeat.
A legal identifier is a name, not a built-in feature.
What $() Means in jQuery and Other Code
Parentheses after an expression perform a function call. In $(argument), $ is the expression that supplies the function, and argument is passed to it.
jQuery commonly makes its main jQuery function available through the shorter name $. That permits calls such as this:
$("button").addClass("ready");
In a page where jQuery controls $, the call selects matching elements through jQuery and then calls a jQuery method. This fragment depends on jQuery and does not print console output.
But $() is not built-in jQuery syntax. JavaScript only sees a call to a value named $. The binding could come from your own declaration:
const $ = (selector) => `Selected: ${selector}`;
console.log($(".notice"));
Selected: .notice
The function receives ".notice" and returns a string. No jQuery behavior exists because this $ refers to the arrow function declared on the first line. Function expressions covers the same idea with more conventional function names.
A binding can also arrive through a parameter:
const formatDraft = (text) => text.toUpperCase();
function runWith($) {
return $("draft ready");
}
console.log(runWith(formatDraft));
DRAFT READY
Inside runWith, $ is the parameter. The call runWith(formatDraft) assigns the formatDraft function to that parameter, so $("draft ready") calls formatDraft.
An imported binding can work the same way. A module might import a function under the local name $, after which $() calls that imported function. The local declaration or import tells you more than the spelling does.
jQuery itself can also relinquish control of the $ variable through jQuery.noConflict(). Code that assumes every $() call is jQuery can therefore be wrong even on a page that loads jQuery.
When you encounter $(), ask one question first: where was $ defined?
What ${…} Means in a Template Literal
A template literal is a string-like expression delimited by backticks. Inside it, ${expression} marks a substitution: JavaScript evaluates the expression, converts its result for inclusion in the template, and inserts it into the resulting string.
Start with a name and a calculation:
const item = "notebook";
const quantity = 3;
const price = 4;
console.log(`${quantity} ${item}s cost $${quantity * price}`);
3 notebooks cost $12
The first ${...} inserts quantity, the second inserts item, and the third evaluates quantity * price before inserting 12. The $ immediately before the final placeholder is ordinary text, so the result contains $12.
The braces can hold an expression rather than only a variable name. Property access, arithmetic, and function calls can all produce the value that is inserted. Strings develops template literals alongside ordinary quoted strings.
Single and double quotes do not activate ${...}:
const price = 12;
console.log("Total: ${price}");
console.log('Total: ${price}');
console.log(`Total: ${price}`);
Total: ${price}
Total: ${price}
Total: 12
The first two lines contain ordinary quoted strings, so the characters remain unchanged. Only the backtick-delimited template evaluates the placeholder.
To produce the literal characters ${price} inside a template literal, escape the dollar sign with a backslash:
const price = 12;
console.log(`Value: \${price}`);
console.log(`Value: ${price}`);
Value: ${price}
Value: 12
The backslash prevents the first ${ from starting a substitution. The second line has no escape, so JavaScript evaluates price.
${...} is template-literal syntax only when it appears inside backticks.
What $ Means in Regular Expressions and replace()
Regular-expression patterns and replacement strings give $ two more jobs. They belong to separate stages: the pattern finds a match, and the replacement string describes what should be inserted.
$ at the end of a regular expression
Inside a regular-expression pattern, $ is an assertion that succeeds at the end of the input. An assertion checks a position without consuming a character.
Here is a pattern that accepts text ending in "end":
console.log(/end$/.test("weekend"));
console.log(/end$/.test("ending"));
true
false
"weekend" ends with "end", so the first test succeeds. "ending" contains the same letters near the beginning, but they are not at the end, so the second test fails.
$ succeeds only when the match reaches the input boundary.With the multiline m flag, $ can also succeed before a line terminator. This example inserts ! at the end position of each line:
const colors = "red\nblue";
console.log(colors.replace(/$/gm, "!"));
red!
blue!
The g flag finds every matching position, while m lets $ recognize the end of each line. Without multiline mode, the pattern concerns the end of the whole input.
$ tokens in a replacement string
The second argument passed to replace() can be a replacement string. Within that string, particular dollar-prefixed tokens insert parts of the match:
$$inserts a literal dollar sign.$&inserts the complete matched text.$1through$99insert numbered capture groups when those groups are present.$<name>inserts a named capture when a matching named group is available.$`inserts the text before the match.$'inserts the text after the match.
Start with $$ and $&:
const label = "Fee 25";
console.log(label.replace(/\d+/, "$$$&"));
Fee $25
The pattern matches "25". In the replacement, $$ produces a literal $, and $& puts the matched "25" back after it.
Numbered captures let you rearrange parts of a match:
const date = "2026-09-18";
const rearranged = date.replace(
/(\d{4})-(\d{2})-(\d{2})/,
"$3/$2/$1"
);
console.log(rearranged);
18/09/2026
The three parenthesized groups capture the year, month, and day. $3, $2, and $1 insert those captures in reverse order.
Named captures use $<name> instead:
const person = "Ada Lovelace";
const reordered = person.replace(
/(?<first>\w+) (?<last>\w+)/,
"$<last>, $<first>"
);
console.log(reordered);
Lovelace, Ada
The pattern names its captures first and last. The replacement reads those names directly, which makes the rearrangement visible without counting parentheses.
The two remaining tokens insert text from outside the match:
const colors = "red green blue";
console.log(colors.replace(/green/, "<$`>"));
console.log(colors.replace(/green/, "<$'>"));
red <red > blue
red < blue> blue
For the first replacement, $` contributes "red ", the text before "green". For the second, $' contributes " blue", the text after it. replace() also preserves the original unmatched prefix and suffix, so each inserted portion appears beside its original copy.
These tokens are not template substitutions. They work inside a replace() replacement string, use no braces except for named captures, and refer to the current replace() match rather than arbitrary JavaScript expressions. Numbered and named capture tokens require the corresponding capture groups in a regular expression.
How to Identify What $ Means in Unfamiliar Code
A dollar sign becomes manageable when you trace context before guessing at a convention. Use the same sequence each time:
-
Inspect the delimiters around
$. Backticks and${...}indicate a template substitution. Slashes around a pattern can make$an end assertion. Quotes in the replacement argument ofreplace()can contain replacement tokens. -
If you see
$or$(), search for a declaration such asconst $,let $,function $, or a parameter named$. The nearest accessible declaration tells you which value the identifier holds. -
Check module imports. An import can introduce
$as a local name even when the exported function has another name. -
Check enclosing function parameters. A caller may supply the
$function, asrunWith(formatDraft)did earlier. -
Check the scripts and libraries the page loads. jQuery may provide
$, but another dependency or application script may assign the same name. -
Treat browser-console and framework conventions as local behavior. In the Chrome DevTools console,
$()is a console-only shortcut fordocument.querySelector()when the page has not defined$; a page-defined$, such as jQuery’s, can override that shortcut. This convenience meaning is not part of JavaScript itself.
If several declarations exist, scope decides which one the expression reaches. Following the name outward through its enclosing blocks and functions reveals the active binding. Following execution from source text to running code makes that lookup easier to place within the larger process.
Then test the value directly when the environment allows it:
const $ = (value) => value.length;
console.log(typeof $);
console.log($("draft"));
function
5
typeof $ reports that the current binding holds a function, and the next line shows what this particular function returns. That evidence is stronger than recognizing a familiar character and assuming jQuery.
The same habit applies across JavaScript: identify the syntax, find the binding, and inspect the value. JavaScript Fundamentals develops those steps across variables, functions, strings, regular expressions, and the rest of the language.
Frequently asked questions
What does $ mean in JavaScript?
Does $ always mean jQuery?
$, but JavaScript treats $ as an ordinary identifier. Another library, an application, a function parameter, or your own declaration can assign it a different value.What does ${} mean in JavaScript?
${expression} evaluates the expression and inserts its value into the resulting string. The same characters inside single or double quotes remain ordinary text.What does $ mean in a JavaScript regular expression?
$ asserts that the current position is at the end of the input. With multiline mode, it can also match a position before a line terminator.