To list all method names of HTMLElement class (or Html node object)

60 views Asked by At

How to obtain list of all method names of HTMLElement class for Html node instance/object
As tried REPL on JSdom installed node js:

$ node
Welcome to Node.js v21.6.0.
Type ".help" for more information.

> const { JSDOM } = require('jsdom'); const dom = new JSDOM('<!DOCTYPE html>')
undefined
> (node:7523) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> const document = dom.window.document
> nodeObj = document.createElement('div');
HTMLDivElement {}
>
> const methodNames = [];
undefined
> for (const key in nodeObj) {
   if (typeof nodeObj[key] === 'function' && nodeObj.hasOwnProperty(key)) {
     methodNames.push(key);
   }
 }
undefined
>
> console.log(methodNames);
[]

Gave only empty array
Please help achieve it more practical, correct way

0

There are 0 answers