Skip to content

Can I help update the declaration of variables?. A good practice! #38

@jdavidleon

Description

@jdavidleon

Scope

let var const

function hi () { alert("hi") }

hi = function () { alert("hello") }

console.log(hi());  //"hello"

better

const hi = function () { alert("hi") }

hi = function () { alert("hello") }

console.log(hello);  // Uncaught TypeError: invalid assignment to const 'hi'
let obj = {};
obj = "string"; //"string"

better

const obj = {};
obj = "string";  // Uncaught TypeError: invalid assignment to const 'obj'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions