What is the difference between synchronous and asynchronous programming (in node.js)

前端 未结 10 1594
情歌与酒
情歌与酒 2020-11-22 01:49

I\'ve been reading nodebeginner And I came across the following two pieces of code.

The first one:

    var result = database.query(\"SELECT * FROM hu         


        
10条回答
  •  离开以前
    2020-11-22 02:16

    The function makes the second one asynchronous.

    The first one forces the program to wait for each line to finish it's run before the next one can continue. The second one allows each line to run together (and independently) at once.

    Languages and frameworks (js, node.js) that allow asynchronous or concurrency is great for things that require real time transmission (eg. chat, stock applications).

提交回复
热议问题