Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: "Deprecated"

Tags:

javascript

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.

like image 667
TawansiForLife TFL Avatar asked Apr 13 '26 21:04

TawansiForLife TFL


1 Answers

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)
})()
like image 135
programmerRaj Avatar answered Apr 20 '26 04:04

programmerRaj