skip to Main Content

Test urls in an array in JavaScript

I am trying to use something like this write a function in JavaScript that loops through an array of urls. Once a 'pingable' url is found the function should return its index number. function ping(url: string): Promise { return new…

VIEW QUESTION

JavaScript – sync + asyns code exectuction order – I want to understand why the logs are displayed in that order

Here is my piece of Vanilla TS code that I am trying to understand: console.log("-------------------------- (LOG 1)"); setTimeout(() => console.log("-----------------------------(LOG 2)"), 1000); const fetchedData = fetch("https://pokeapi.co/api/v2/pokemon/ditto"); const fnReturningNewPromise = () => { return new Promise<string>((resolve, reject) => { if (1…

VIEW QUESTION
Back To Top
Search