2

Here is my Javascript code on VS Code:

const name var name

In the console.log(name variable); the name variable is displayed with a strikethrough symbol on VS Code. But the result showing on my browser is right (no error).

Also, the tooltip shown on VS Code is "const name : void".

The same thing is happening if I use

document.getElementById('demo10').innerHTML = name;

or

document.write(name);
var name = 'Smith';
document.getElementById('demo10').innerHTML = name;
console.log(name);
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135

3 Answers3

2

Short Answer:

name is an obsolete property of the Window object. When you see a strikethrough on a variable, VS Code knows that it is deprecated.

Long Answer:

What is the name keyword in JavaScript?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
0

It is a deprecated variable. This is particularly annoying on loops when we are just using the index of an array, or a foreach(). To stop this behavior add this to your user settings JSON file. This may help someone out in the future.

// Controls strikethrough deprecated variables.
"editor.showDeprecated": false,

In the most recent versions there is also a checkbox in the UI settings under "editor".

sdforet
  • 67
  • 1
  • 2
-1

Better update the version of vs code in the new one there is more shortcuts and no annoying errors. thanks

Nahom
  • 34
  • 4