H
H
heIIfire2018-03-12 17:05:25
JavaScript
heIIfire, 2018-03-12 17:05:25

Why is the presence of event checked?

function handleClick(event){
event && event.preventDefault();
// ......
}
In what situations can event be undefined?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-03-12
@webinar

If not transferred. This is a function, anything can be inside event, like undefined, for example

handleClick(); //вызвали, но не передали, а можно и передать undefined на самом деле
function handleClick(event){
console.log(event); //undefined
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question