我对此很有信心function declarations does not has lexical context
,arrow function it does have
但我很困惑,如果function expression does
?
根据我读到的内容,它没有,但在following example
两种情况下都可以正常工作(使用函数表达式和箭头函数),所以在我看来它has lexical context
。在我理解之后arrow function
,它就是short syntax of the function expression
这样same capacities
。我错了吗?
查看未注释的代码:
// Delete users for ADMIN with GET
document.addEventListener("click", function (e) {
if (e.target.classList.contains("btnDeleteUser")) {
/// get users based on id
sUserId = e.target.getAttribute("data-userId");
//console.log(sUserId);
/*getAjax("api_delete_user.php?id=" + sUserId, function(ajUserDataFromServer) {
deleteUser(e, ajUserDataFromServer);*/
/*getAjax("api_delete_user.php?id=" + sUserId, (ajUserDataFromServer) => {
deleteUser(e, ajUserDataFromServer);
})*/
getAjax("api_delete_user.php?id=" + sUserId, deleteUser.bind(this, e));
}
});