[system] initColorSchemeScript.tsx uses var instead of let
Summary
We use var:
https://github.com/mui/material-ui/blob/9f4b846be96ee18733b6bd77eba2f54b1ceb9b04/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.tsx#L95
but this seems confusing. Why not let? For example, https://github.com/pacocoursey/next-themes/blob/bf0c5a45eaf6fb2b336a6b93840e4ec572bc08c8/next-themes/src/script.ts#L14 who use modern syntax.
Using let over var seems to have two benefits:
- It's less prone to bugs https://sentry.io/answers/difference-between-let-and-var-in-javascript/.
- It's easier to debug for developers, I would expect developers to not be used anymore to read code who uses
var.
Motivation
I was confused by this looking into #43416.
Hi, would you like to create a PR?
Hi, would you like to create a PR?
Hey @ilyastorunn! I can do that, but go ahead if you have one ready.
Hi @oliviertassinari, var might have been used because the code was written in an environment where ES6 (let and const) was not supported, or it’s older code.
I can pick this up if you like?