Console output sequence sometimes does not match with the sequence in which they are called

192 views Asked by At

I am new to JavaScript and this is my first question on Stackoverflow, please let me know if I missed something which should be included in the question.

Question 1: Can anyone explain why sometimes the console output sequence does not match with the sequence in which they are called (myFunction(); and messageLogger();).

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test Page</title>
</head>
<body>
    <script>
        let myFunction = function messageLogger() {
            console.log('Message Logged');
        }
        myFunction();     //Should output message in console
        messageLogger();  //Should generate error in console
    </script>
</body>
</html>

This is Basic Function Expression code as shown above and in the image Original Code Image.

This code should show error in console after running myFunction(); as in image Console Output Image 1, but sometimes show's error before running myFunction(); as in image Console Output Image 2.

1

There are 1 answers

0
AtlasUser5 On

I haven't seen the problem after I updated the MS Edge Browser to Chromium version. I have no reason and solution to actual cause but issue cannot be seen anymore.