The cancelable of Event for JS returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
<!doctype html>
<html>
<body>
<output></output>
<script>
const type = "mytype";
const eventInitDict =
{
cancelable: true
};
const event = new Event(type, eventInitDict);
document.querySelector("output").innerHTML = event.cancelable;
</script>
</body>
</html>
<!doctype html>
<html>
<body>
<output></output>
<script>
function callback(myparameter)
{
document.querySelector("output").innerHTML = myparameter.cancelable;
}
const type = "mytype";
const event = new Event(type);
const target = new EventTarget();
target.addEventListener(type, callback);
target.dispatchEvent(event);
</script>
</body>
</html>
<!doctype html>
<html>
<body>
<output></output>
<script>
function callback(myparameter)
{
document.querySelector("output").innerHTML = myparameter.cancelable;
}
const type = "mytype";
const eventInitDict =
{
cancelable: true
};
const event = new Event(type, eventInitDict);
const target = new EventTarget();
target.addEventListener(type, callback);
target.dispatchEvent(event);
</script>
</body>
</html>
<!doctype html>
<html>
<body>
<button>button</button>
<output></output>
<script>
function callback(myparameter)
{
document.querySelector("output").innerHTML = myparameter.cancelable;
}
const type = "mouseover";
const event = new Event(type);
const target = document.querySelector("button");
target.addEventListener(type, function(){callback(event)});
</script>
</body>
</html>
<!doctype html>
<html>
<body>
<button>button</button>
<output></output>
<script>
function callback(myparameter)
{
document.querySelector("output").innerHTML = myparameter.cancelable;
}
const type = "mouseover";
const target = document.querySelector("button");
target.addEventListener(type, callback);
</script>
</body>
</html>