Skip to content

Author: admin@master

TypeScript export vs. default export

What is the difference in TypeScript between export and default export? In all the tutorials, I see people exporting their classes and I cannot compile my code if I don’t add the default keyword before exporting. Also, I couldn’t find any trace of the default export keyword in the official TypeScr…

Why do we write window.?

While adding some initialisation code to a webpage, I found myself writing window.onload = … for the umptieth time, when a thought hit me. The window. isn’t necessary, because window is the current object. So it’s optional! But nobody writes just onload = … and I wonder why that is. I …

Saving JSON in Electron

I am building an app using Electron. In this app, I am building a data structure using JSON. My data structure looks like this: I want to save this JSON to a file called “data.json”. I want to save it to a file because I want to load the next time the application starts. My challenge is, I do not

Find last matching object in array of objects

I have an array of objects. I need to get the object type (“shape” in this example) of the last object, remove it, and then find the index of the previous object in the array that has the same type, e.g. “shape”. So, obviously the type in this example will be “round”. But I…

Prevent redirect when clicking on anchors child element

I have a button that’s located in an anchor, and that button has some logic that’s triggerd by clicking on it. The problem is that whenever I click on that button, the app get’s redirected due the anchor parent element. I tried using .stopPropagation() like it’s mentioned in this post,…