Why TypeError occurs? [duplicate]

1

Hello, I am studying javascript and doing some testing and would like to understand why this form of call generates error.

function test (){
    function printA(){
        console.log("a");
    }
}
test.printA();

Uncaught TypeError: test.printA is not a function
    at <anonymous>:1:6
function test (){
        function printA(){
            console.log("a");
        }
        printA();
    }
test();
a
    
asked by anonymous 14.11.2017 / 15:07

0 answers