I confident about that function declarations does not has lexical context
and arrow function it does have
, but I am confused if function expression does
?
According to what I read it doesn't but in the following example
it works fine both ways( with function expression and arrow function ) so it seems to me it has lexical context
. After my understanding arrow function
it's just the short syntax of the function expression
so it has the same capacities
. Am I wrong?
See the uncommented code:
// 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));
}
});