Skip to content

Tag: javascript

JS call static method from class

I have a class with a static method: Is there an equivalent to this for static methods (i.e. refer to the current class without an instance)? So I don’t have to write the class name: “User”. Answer From MDN documentation Static method calls are made directly on the class and are not callable…

Typescript/Javascript: using tuple as key of Map

Hit this odd bug in my code and I can’t figure the way to get a constant time lookup from a Map when using a tuple as my key. Hopefully this illustrates the issue, and the workaround I’m using now just to get it to work: hello.ts: To compile (transpile?) I’m using: tsc version 2.1.6 Tried se…

Chaining vanilla javascript traversal?

My HTML looks like this: I am currently selecting the parent node of the panel-heading element like so: This leaves me with the panel class. All is well. But now I would like to grab the panel-body at that point. Doing something like this unfortunately does not work: Is there a clean way to do this in vanilla…