IT quiz
All questions
Sign in
Sign up
JavaScript
HTML
CSS
PostgreSQL
PHP
Linux
Git
Docker
SCSS
TypeScript
SQL
Vue
DNS
Go
frontend (web)
Redis
backend
Gitlab
CI/CD
Vite
webpack
Node.js
HTTP
Python
Kotlin
Nuxt
Question #22
Author:
admin
tags:
JavaScript
A regular object has been created:
let obj = { x: 1 };
Is it possible to add an event listener to this object by calling the
obj.addEventListener()
method on it?
No
Yes, in any browsers.
Yes, but only in browsers with ECMAScript 6+ support.
Answer
Show explanation
An event listener cannot be added to an ordinary object created via a literal using native methods.
To use native browser methods, an object must implement the EventTarget interface.
Support for the EventTarget() constructor has appeared in browsers since Firefox 59 and Chrome 64.
Rate the difficulty of the question:
1
2
3
4
5
6
7
8
9
10
easy
hard
←
Previous question (JavaScript)
Next question (JavaScript)
→
Write new comment