Skip to content

Attaching method to function prototype

I’m trying to attach a method mytest to a function prototype: But I get: Uncaught TypeError: Cannot set property ‘mytest’ of undefined” Answer Even if you fix the fact that the arrow function has no prototype by using a regular function, you cant assign to the prototype of the value re…

TypeScript cant read property addEventListener

I’m learning TypeScript and I’m following a youtube tutorial that I did step by step. But for some reason I’m still receving a error. Uncaught TypeError: Cannot read property ‘addEventListener’ of null I rewrote the code twice and I’m still receiving the same error. Could u…

Add/Remove CSS Class with JS Loop

I have a navigation menu that displays a group of notes from the clicked topic. The note can either have class note if it is visible or class invisible if it is hidden. I want only the notes from the topic clicked to show. The problem is that some notes from other topics are also being shown. Even though the

React setState does not update a state array value

I am trying to change the state in a class component by using setState. More specific I have a table, and I want to edit/update one of its elements. For this case, I am passing the indeces to the handleTableFieldOnChange function for the position of the value in the array. Since I know that I should not mutat…

toString() method vs string representation

I have: In the second line, what does the notation using square brackets mean? The console.log() documentation says the “string representation” of the object argument is printed. If that is not the same as the toString() function of the Number object, where is the string representation of an objec…