JavaScript is an explanatory language.
Python is also an explanatory language.
For an explanatory language, you need to know the language's integrated development environment, such as the command line.
The sync in Python,
For x in [1,2,3,4,5,6,7,8,9,0]
y = 0
While y < 1000000:
Y + = 1
Print X
Async in javascript:
FS = require (' FS ');
Fs.writefile ('./write.txt ', ' Hello world! ', function (err) {
if (err) throw err;
Console.log (' Oh, it writes successfully! ');
Console.log ("I ' m async and I'll show later");
}
Console.log ("haha,in fact, I ' M sync and I'll show earlier");
Using Python and node respectively to run the above two pieces of code, you can feel the difference.
Personally think, callback callback, back to call again.
There is a saying, "You are waiting for me, I will come back", personally think is almost the async.
* * * anonymous function used as closure * * *
var Baz;
(function () {var foo = 10; var bar = 2; Baz = function () {return foo*bar; }; })();
Javascript has ***function level*** scope. * This means a variable defined within a function is ***not*** accessible ***outside*** of it.
try {
Console.log (foo);
}
catch (Err) {Console.log (err);} try {
Console.log (bar); } catch (Err) {Console.log (err);}
Javascript has ***lexcially level*** scope. * This means functions run in the scope they is ***defined in***, ***not*** the scope they is ***excuted in***. Console.log (Baz ());
JavaScript Async and sync--a simple code