dimanche 28 juin 2020

If-statement does not work inside Arrow-function [duplicate]

$('#title').keyup( () => {
    const title_val = $(this).val();
    console.log('before');
    if (title_val.length >= 20){
        console.log(title_val);
    }
    console.log('after');
});

console.log('before') and console.log('after') works. If-statement only works if I use function() instead of () => {...}, even if the condition is satisfied. Why does it behave like this?

Aucun commentaire:

Enregistrer un commentaire