How Can I find any Object when I know property value of object

I try create shortcut to icon (html element), which is object and this object has some methods for example. openWindow(), and I want that, when I will click on shortcut,this shortcut run method this object (orginal html element).


class File{
  constructor(fileName){ = fileName;
  this.element = document.createElement("div");
    console.log("You opened",;

const orginalElement = new File("file1");

const shortcut = orginalElement.cloneNode(true);
shortcut.addEventListener('click', openWindow);

Maybe I should use WeakMap or something other I don’t know.
So Is any method, which can return object when I know property value of object?
Because in my code each object has ‘id’ property and thoose shortcuts has attribute ‘id’ which should be same as property id of orginal object.

Leave a Comment