How to understand this piece of JS code?

I saw this code when I was looking at ES6. I don"t quite understand this code. I don"t know about scope.

related codes
{
    function fooc() { return 1 }
    {
        function fooc() { return 3 }
    }
    console.log(fooc())
}
console.log(fooc())

//
1
3
Why not all 3, or why not all 1?
Sep.16,2021

you are looking at the block-level scope of ES6. A single pair of curly braces will generate a block-level scope, and the function will be promoted to the top of the current scope

.

= the above is a simple answer to see the question using the mobile phone =

use the computer to test the results

clipboard.png

,

: ECMAScript 6

ES6

babel

clipboard.png

node1

clipboard.png

clipboard.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45be9-44b5a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45be9-44b5a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?