The error indicates that msSpeechRecognition is being accessed from the window object as window.msSpeechRecognition. You can only add something to globalThis by declaring it with var. If you want to use const instead, you will need to replace references to window.msSpeechRecognition with just msSpeechRecognition.
Medium
medium.com โบ @robinviktorsson โบ understanding-the-differences-between-var-let-and-const-in-javascript-and-typescript-0ddd90c0b672
Understanding the Differences Between var, let, and const in JavaScript and TypeScript ๐ป | by Robin Viktorsson | Medium
March 10, 2025 - It's ideal for constants, objects, or arrays where you don't want to change the reference, but you may need to modify the object itself. In modern JavaScript/TypeScript, avoid using var unless absolutely necessary.
Reddit
reddit.com โบ r/typescript โบ var, const, let
r/typescript on Reddit: var, const, let
April 24, 2018 -
I confuse the following term var, const, let in typeScript and when should I use them?
Top answer 1 of 4
34
Rule of thumb: start with const, if you need to change the value later, change to let, and forget about var.
2 of 4
17
let - use this when you are declaring a variable to be used in a scope and possibly re-assigned later. const - use this when you know you never need to re-assign to the variable. assign when you declare and never again. var - don't use this. it's old and pointless. That's it!
var, const, let
Rule of thumb: start with const, if you need to change the value later, change to let, and forget about var. More on reddit.com
Difference between var, let and const
Using the function keyword creates a function declaration. Function declarations are hoisted to the top of the scope, thus the following code works fine: add(1, 2) function add (a, b) { return a + b } There are readability advantages to using the function keyword as it clearly communicates that this is a function. We can also create an anonymous function expression and, because functions in JavaScript are first class citizens, assign a function to a named variable with let, const or var. Keep in mind though, variables declared with let and const are hoisted, but not initialized with a value. Whereas variables declared with var are hoisted and initialized with the value undefined. So because add is invoked prior to it's initialization in the code below we encounter an error. With let/const: add(1, 2) // Reference error - cannot access 'add' before initialization const add = function (a, b) { return a + b } With var: add(1, 2) // Type error - 'add' is not a function (as it is initialized as undefined when hoisted) var add = function (a, b) { return a + b } If you're assigning a function to a variable I can't think of any situation where you wouldn't use const. Functions should always be pure and immutable whenever possible. Given a certain input, the output should always be consistently the same. Using const protects you from accidentally reassigning a variable containing a function expression. Compare this to use of the function keyword, which allows you to declare a named function twice, overiding the previous: function add (a, b) { return a + b } function add (a, b) { return a - b } add(2, 1) // 1 This is a disadvantage of function declarations versus expressions. Provided you understand the pros/cons and how hoisting works, it is really personal choice whether you prefer function declarations versus expressions. More on reddit.com
Videos
01:35
What's the difference between var, let, and const? | JavaScript ...
08:48
var, let, and const: What is the Big Difference! - YouTube
04:27
var, const, let... now โusingโ? - YouTube
08:37
Differences Between Var, Let, and Const - YouTube
09:45
Chapter 13 - Angular Tutorial - Typescript let var const - YouTube
GeeksforGeeks
geeksforgeeks.org โบ javascript โบ difference-between-var-let-and-const-keywords-in-javascript
Difference between var, let and const keywords in JavaScript - GeeksforGeeks
This happens because let variables are hoisted but not initialized, so they remain in the TDZ until the declaration is executed. ... Hoisting with const: The variable x is declared with const, which is block-scoped and not hoisted.
Published ย January 16, 2026
Gazar
gazar.dev โบ typescript โบ when-to-use-let-vs-const
When to Use let vs const in TypeScript | Gazar
const PI = 3.14; PI = 3.14159; ... your intent and reduce the cognitive load on readers of your code." In TypeScript, the choice between let and const boils down to intent and necessity....
DEV Community
dev.to โบ hexnickk โบ js-interview-in-2-minutes-var-let-const-39p1
JS interview in 2 minutes / var โ๏ธ let โ๏ธ const - DEV Community
February 15, 2022 - Quick answer: These are a few ways to declare variables. var is a legacy one, let and const are new ones, where let is for mutable variable reference and const is for immutable reference.
Scaler
scaler.com โบ home โบ topics โบ javascript โบ difference between var, let, and const in javascript
Difference Between Var, Let, and Const in Javascript | Scaler Topics
June 21, 2024 - Var is function-scoped and can be both re-declared and updated, making it the more flexible, yet potentially riskier option from older JavaScript standards. In contrast, Let, introduced in ES6, is block-scoped and can only be updated, not ...
Stack Abuse
stackabuse.com โบ the-difference-between-var-let-and-const-in-javascript-and-best-practices
The Difference Between var, let and const in JavaScript and Best Practices
May 22, 2023 - Avoid using var. let is preferred to const when it's known that the value it points to will change over time.
Cloudhadoop
cloudhadoop.com โบ home
Typescript let, var, Const keyword with examples | Javascript | ES6
March 6, 2024 - Attempting to redeclare the same ... variable value. ... const is similar to let, but variables declared with const must be initialized immediately and cannot be reassigned:...
Gitbooks
basarat.gitbooks.io โบ typescript โบ content โบ docs โบ const.html
const ยท TypeScript Deep Dive
To use const just replace var with const: