diff --git a/CHANGES.md b/CHANGES.md
index 3b74e41ab3..7d32ad5dec 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -17,6 +17,7 @@ Grammars:
- enh(cmake) support bracket comments [Hirse][]
- enh(java) add yield keyword to java [MBoegers][]
- enh(java) add permits keyword to java [MBoegers][]
+- fix(javascript/typescript) correct identifier matching when using numbers [Lachlan Heywood][]
[Josh Goebel]: https://github.com/joshgoebel
[Josh Temple]: https://github.com/joshtemple
@@ -26,6 +27,7 @@ Grammars:
[Hirse]: https://github.com/Hirse
[The Flix Organisation]: https://github.com/flix
[MBoegers]: https://github.com/MBoegers
+[Lachlan Heywood]: https://github.com/lachieh
## Version 11.6.0
diff --git a/src/languages/javascript.js b/src/languages/javascript.js
index 6db241a4af..e999cc66fe 100644
--- a/src/languages/javascript.js
+++ b/src/languages/javascript.js
@@ -220,6 +220,8 @@ export default function(hljs) {
HTML_TEMPLATE,
CSS_TEMPLATE,
TEMPLATE_STRING,
+ // Skip numbers when they are part of a variable name
+ { match: /\$\d+/ },
NUMBER,
// This is intentional:
// See https://github.com/highlightjs/highlight.js/issues/3288
@@ -453,6 +455,8 @@ export default function(hljs) {
CSS_TEMPLATE,
TEMPLATE_STRING,
COMMENT,
+ // Skip numbers when they are part of a variable name
+ { match: /\$\d+/ },
NUMBER,
CLASS_REFERENCE,
{
diff --git a/test/markup/javascript/numbers.expect.txt b/test/markup/javascript/numbers.expect.txt
index 1fd58c42fa..f15c1081d6 100644
--- a/test/markup/javascript/numbers.expect.txt
+++ b/test/markup/javascript/numbers.expect.txt
@@ -75,3 +75,24 @@ x0.e1
0b1e1
0N
00.
+
+
+const num = $1
+const num = $0n9
+const num = $abc012
+const num = $0x9
+const num = $0o0
+const num = $09
+const num = $9.09
+const num = $a9
+const num = 1
+const num = 0n9
+const num = 0x9
+const num = 0o0
+const num = 09
+const num = 9.09
+const num = a9
+
+
+cosnt string = `${$0}`
+cosnt string = `${0}`
diff --git a/test/markup/javascript/numbers.txt b/test/markup/javascript/numbers.txt
index 05baf74710..daa651082b 100644
--- a/test/markup/javascript/numbers.txt
+++ b/test/markup/javascript/numbers.txt
@@ -75,3 +75,24 @@ x0.e1
0b1e1
0N
00.
+
+// numbers in identifiers
+const num = $1
+const num = $0n9
+const num = $abc012
+const num = $0x9
+const num = $0o0
+const num = $09
+const num = $9.09
+const num = $a9
+const num = 1
+const num = 0n9
+const num = 0x9
+const num = 0o0
+const num = 09
+const num = 9.09
+const num = a9
+
+// numbers in identifiers in template strings
+cosnt string = `${$0}`
+cosnt string = `${0}`