In the following case, X is not assigned, so why return 6?

function myFunction(a,b) {
    if (a>b) 
    {return; }
    x=a+b };
myFunction(2,1); 
console.log(x);//6

this is an example of the use of return in the runoob Javascript function page. I want to try what the value of x will be if it is returned directly in accordance with the if condition. As a result, the console returns 6. How does this work?

Mar.23,2021

VM148:6 Uncaught ReferenceError: x is not defined
    at <anonymous>:6:13

if this is the only part of the code plus the global variable x, x will not be 6, is it your external code to assign a value to x? You can try


before declaring another variable. You can use var to assign a value to x before.


tried undefined. Check the code and post all


this x is a global variable. You set x = 6 somewhere else; it is recommended to read a book and read it from the beginning.


you didn't write the code directly on the console, and then there was an x that was 6.


Uncaught ReferenceError: x is not defined at : 6:13
the x is not defined in the code. You may have defined the global x 6 somewhere else, so it appears that the x you said printed out is 6

.
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-7af5e3-24866.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-7af5e3-24866.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?