如何在JavaScript中将事件对象转换为字符串?

Asm*_*ita 5 javascript jquery

我想要发生哪个事件::

function getEvent(){
    alert(window.event);
}
Run Code Online (Sandbox Code Playgroud)

我在事件对象之下.我希望它在字符串中进行比较.如果事件onclick事件,那么我想做的动作.我怎么能用字符串得到它?或者我如何将事件对象转换为字符串?

[object MouseEvent]
Run Code Online (Sandbox Code Playgroud)

Asa*_*din 8

使用type属性. window.event.type