javascript - 这是什么 JS 语法,它是什么意思?
问题描述
首先,很抱歉这个多余的问题,只是还没有找到合适的方法来问这个问题。我正在查看一个使用 React-router 保护路由的视频,当时视频中的家伙写了这样的内容:
class Auth {
constructor() {
this.authenticated = false;
}
login(cb) {
this.authenticated = true;
cb();
}
logout(cb) {
this.authenticated = false;
cb();
}
isAuthenticated() {
return this.authenticated;
}
}
这是让我感到困惑的一点:
login(cb) {
this.authenticated = true;
cb(); // What syntax is this???
}
这到底是做什么的?是否应该将函数作为参数调用她?提前感谢您的帮助!
解决方案
推荐阅读
- jenkins - jenkins 构建配置 - 打包 EAR 问题
- c# - 当名称是保留关键字时,如何从动态对象中获取属性?
- c# - 如何在 ASP net core 中添加扩展过滤器?
- angular - 复选框值不在表单数组中,角度
- javascript - 使用 Jest.fn() 查看是否调用了 s3.upload 函数......我做错了什么?
- java - 如何将 yaml 文件中的变量读入 application.properties?
- javascript - MongoDB $和查询
- image - 如何在 Kivy 的滚动视图中将标签放置在屏幕中央?
- linux - 我可以确保每个 CentOS 7 都有 /etc/os-release 文件吗?
- java - Groovy,jruby 作为 Spring beans