Skip to content

Tag: javascript

set timeout to event listener function

I have an event listener I would like to have a timeout for this event listener. So let’s say that if it doesn’t receive any event called ‘evt’ in 3 seconds I would like to have a notification that it timed out. I tried with the setTimeout function but so far I don’t manage to pa…

Using reduce() to find min and max values?

I have this code for a class where I’m supposed to use the reduce() method to find the min and max values in an array. However, we are required to use only a single call to reduce. The return array should be of size 2, but I know that the reduce() method always returns an array of size 1. I’m

fetch response.text() returns pending promise

I test the fetch API with jsonplaceholder URL, but my function returns “Promise State: Pending”, and I don’t understand why : I think the problem is because of asynchronous/synchronous methods? Answer I think the problem become asynchrone/synchrone method ? Yes. You’ve (mostly) correct…

How to Import a Single Lodash Function?

Using webpack, I’m trying to import isEqual since lodash seems to be importing everything. I’ve tried doing the following with no success: Answer You can install lodash.isequal as a single module without installing the whole lodash package like so: When using ECMAScript 5 and CommonJS modules, you…