Home > Web Front-end > JS Tutorial > js callback simple code example

js callback simple code example

小云云
Release: 2018-03-07 10:28:45
Original
1380 people have browsed it

This article mainly shares a simple code with you, which is a simple code example for js callback. I hope this code can help everyone.

function test(callback) {
   var data = "aaa";
  typeof callback == 'function' && callback(data)
    }



test(function (data) {

  console.log(data);

 });
Copy after login
typeof  callback   输出callback的类型
== 'function'        
等于function(函数)&& callback(data)         
&&前面的为真,则执行&&后面的语句 callback(data),  data为需要传递的函数参数,
Copy after login

Related recommendations:

JS callback asynchronous

A simple example of the application of JS callback function_javascript skills

Blocking and non-blocking calls of node.js callback functions_node.js

The above is the detailed content of js callback simple code example. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template