我对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));
}
});