aboutsummaryrefslogtreecommitdiff
path: root/files/vi/glossary/callback_function
diff options
context:
space:
mode:
authorFlorian Merz <me@fiji-flo.de>2021-02-11 14:51:56 +0100
committerFlorian Merz <me@fiji-flo.de>2021-02-11 14:51:56 +0100
commit904a5994c87295d84d25f869d5555f35fbce5070 (patch)
treea8535dfa32d2180186965a0bb66931b4830c5d73 /files/vi/glossary/callback_function
parent8260a606c143e6b55a467edf017a56bdcd6cba7e (diff)
downloadtranslated-content-904a5994c87295d84d25f869d5555f35fbce5070.tar.gz
translated-content-904a5994c87295d84d25f869d5555f35fbce5070.tar.bz2
translated-content-904a5994c87295d84d25f869d5555f35fbce5070.zip
unslug vi: move
Diffstat (limited to 'files/vi/glossary/callback_function')
-rw-r--r--files/vi/glossary/callback_function/index.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/files/vi/glossary/callback_function/index.html b/files/vi/glossary/callback_function/index.html
new file mode 100644
index 0000000000..5aabc5fcc4
--- /dev/null
+++ b/files/vi/glossary/callback_function/index.html
@@ -0,0 +1,27 @@
+---
+title: Callback function
+slug: Tu-dien-thuat-ngu/Callback_function
+translation_of: Glossary/Callback_function
+---
+<p>Hàm gọi lại là một hàm được truyền vào một hàm khác dưới dạng đối số, sau đó được gọi bên trong hàm bên ngoài để hoàn thành một số loại quy trình hoặc hành động.  Đây là một ví dụ nhanh:</p>
+
+<pre class="brush: js notranslate">function greeting(name) {
+ alert('Hello ' + name);
+}
+
+function processUserInput(callback) {
+ var name = prompt('Please enter your name.');
+ callback(name);
+}
+
+processUserInput(greeting);</pre>
+
+<p>Ví dụ trên là một lệnh gọi lại {{glossary ("sync")}}, vì nó được thực thi ngay lập tức.  Tuy nhiên, lưu ý rằng các lệnh gọi lại thường được sử dụng để tiếp tục thực thi mã sau khi hoạt động {{glossary ("asynchronous")}} hoàn thành - chúng được gọi là lệnh gọi lại không đồng bộ.  Một ví dụ điển hình là các hàm gọi lại được thực thi bên trong một khối .then () được xâu chuỗi vào cuối một lời hứa sau khi lời hứa đó hoàn thành hoặc bị từ chối.  Cấu trúc này được sử dụng trong nhiều API web hiện đại, chẳng hạn như fetch ().</p>
+
+<h2 id="Learn_more"><strong>Learn more</strong></h2>
+
+<h3 id="General_knowledge"><strong>General knowledge</strong></h3>
+
+<ul>
+ <li>{{interwiki("wikipedia", "Callback_(computer_programming)", "Callback")}} on Wikipedia</li>
+</ul>