《2019年3月29日》【连续 541天】
标题:callback.html;
内容:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
function getTimestamp (done) {
setTimeout(function () {
// 执行调用者指定的事情
done(Date.now())
}, 1000)
}
// ========================================
// 指定拿到数据过后怎么做
var done = function (timestamp) {
console.log(timestamp / 1000 / 60 / 60)
}
getTimestamp(done)
</script>
</body>
</html>
本文提供了一个简单的JavaScript回调函数示例,展示了如何使用回调来获取并处理时间戳数据。
5416

被折叠的 条评论
为什么被折叠?



