HTML:
<button onclick="foo(event);">Test</button>
Javascript:
window.foo = function(event) {
console.log(JSON.stringify(event));
}
Console Result:
{"isTrusted":true}
It is happening on Chrome. I haven't tested other browsers yet.
There are a number of reasons why some properties do not get included in JSON.stringify:
function
s, which cannot be stringifiedIf you need to include extra data, your best bet is to manually construct a fresh object with the things you want to include:
window.foo = function(event) {
console.log(JSON.stringify({keyCode: event.keyCode));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With