Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Javascript: "Deprecated"

Screenshot of message

I am new in learning Javascript and as I was following the tutorial I found that console.log(name); got (name) struck through in such a way claiming it is "Deprecated".

If there is an explanation on what that means or what I should do to remove that strike, I would be really thankful.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Because you used var name = ..., TypeScript thinks you are referring to window.name, which TypeScript considers deprecated. You can fix this error by:

  1. Use a different variable identifier, like anotherName -

var anotherName = 'Bob'

console.log(anotherName)

  1. Move the code inside a function. -

(() => {
  var name = 'bob'

  console.log(name)
})()

about 4 years ago · Juan Pablo Isaza Report

0

I think this is due to the fact that a 'loose' variable in a browser, declared with var, outside of a function is just going to end up pointing to:

window.name 

And window.name has a special meaning, and is indeed deprecated.

It's a quirk of the language. If you didn't intend to create the variable in a global scope, you might be better off just declaring it in a function.

This will not have the same problem:

function main() {
   const name = 'Foo';
}
main();

Generally it's a good idea to avoid creating any global symbols unless you explicitly intend to.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!