第 13 课 · Web前端技术 14 / 22 | 编码:L13-15b
回调与数组方法

从数据集合到页面列表

回调函数是作为参数传入、由另一段代码调用的函数。先理解输入与返回值,再阅读后续 DOM 和 Tab 示例。

const courses = [{ id: 1, title: "HTML" }];
const found = courses.find(item => item.id === 1);
const titles = courses.map(item => item.title);
console.log(found?.title); // HTML
console.log(titles);      // ["HTML"]