Skip to content

Tag: javascript

React JS get current date

I want to output the current date in my componnent. In the console my code works, but the React console says: “bundle.js:14744 Uncaught RangeError: Maximum call stack size exceeded” My component looks like that: Yeah, I know I’m a pretty beginner, but maybe someone can help me. I googled for…

JavaScript: Overwrite property defined in constructor for whole class

I am trying to overwrite the function of a class: But Babel compiles the above to this: Because the function is defined as a property in the original code, Babel puts that definition in the constructor. If I understand correctly prototype only contains functions, not all properties. Because the constructor ru…

Get the first and last item in an Array – JS

I am trying to get the first and last item in array and display them in an object. What i did is that I use the first and last function and then assign the first item as the key and the last item as the value. however this one gets me into trouble. It says undefined. Any idea why is

Why does TypeScript use “Like” types?

Why does TypeScript have a type and then a “like type”? An example of this is Promise<T> and PromiseLike<T>. What are the differences between these two types? When should I use them? In this case why not just have one Promise type? Answer If you look at the definition files (let’…

Can I create an object without a name in JS?

I have a structure that looks like this: I can iterate over them in a loop like this: Do I assume correctly that in the cards array I have a couple of objects without names? If so, how can I push more objects like that to the cards array without giving them names? I want to create those objects in