1

Im coding beginner. I tried import h1 tag So I using document.querySelector function. And I declare variable 'name', but it happens error. why it happens error and how fix that? Fist, This is codes

<!DOCTYPE html>
<html>
    <head>
        <meta charset = "utf-8">
        <title>Test</title>
        <link rel = "stylesheet" href = "style.css">
    </head>
    <body>
        <div class = "title">
            <h1>Grab me!</h1>
        </div>
        <script type = "text/javascript" src = "script.js"></script>
    </body>
</html>
const name = document.querySelector(".title:first-child");
console.dir(name);

It's error(?)

const name: void
@deprecated

'name' is deprecated.ts(6385)
lib.dom.d.ts(17177, 5): The declaration was marked as deprecated here.

I googled but I couldn't find helpful answer (Sorry about my terrible English)

jihan kim
  • 11
  • 2
  • In addition to the comment of phuzi, basically just don't have top-level variables called `name` as there already is a global variable called that. Given that it's deprecated, and you are overwriting it, you could also just ignore the warning. – Elias Jan 28 '22 at 08:23

0 Answers0