The Writing of js function

problem description

when you look at the project code, you can also find that some of the statements in the function are wrapped in curly braces, but there seems to be no difference when you execute them. What"s the use of this?

function a(){
    console.log("<<<<");

    {
        let b = "123";
        console.log(b);
    }

    console.log(">>>");
}

//

<<<<
123
>>>
May.18,2022

isolation scope
  

this is giving the let variable a separate scope

Menu