Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda