how to change .toLocaleString() digits to english?

I try to change a date from Gregorian date to local date (Jalali). with this code: document.write(new Date().toLocaleString(“fa-IR”)) and it returns: ۱۴۰۱/۱۲/۲۲, ۱۱:۴۲:۰۰ But I need to be return output in English digits, like this: 1401/11/22, 11:42:00 >Solution : In toLocaleString the first option is preferred for language, if you want to have an Gregorian… Read More how to change .toLocaleString() digits to english?

Converting an array of strings into an array of objects with key value pairs in javascript

I’m trying to convert the following array of strings string[] to an array of objects with the following format [{"title": value "value": value }] This is the array I get locationQuery = [ "Antwerpen", "Hemiksem", "Antwerpenlei, Brasschaat", "Antwerpenplein, Gent", "Antwerpenstraat, Bredene", "Antwerpenstraat, Oostende", "’s-Herenstraat, Antwerpen", "’t Berkenveld, Antwerpen", "’t Doolhofje, Antwerpen", "’t Duivelshoekje, Antwerpen" ]… Read More Converting an array of strings into an array of objects with key value pairs in javascript

Is a Javascript function (without promises) guaranteed to run without interruption?

For example: let x = 1 setInterval(() => x += 1, 1000) function f() { console.log(x) console.log(x) } When the function is called, are two outputs guaranteed to be the same? Or can the setInterval trigger between these two? I have tried to search MDN web docs on this topic, but I’m unfamiliar with the… Read More Is a Javascript function (without promises) guaranteed to run without interruption?

Shorter random string good enough "locally unique" identifiers?

It seems like many of the methods for producing GUIDs are pretty conservative, producing guids with an astronomically small chance of collision. I’m wondering if, when you are producing key for a map of objects which are very unlikely to exceed 100K, it’s reasonable to use something other than GUID for a typical business application.… Read More Shorter random string good enough "locally unique" identifiers?

how to Extract Link part from a string in javascript

Having a string of the below structure how can i extract only the link portion of it. https://qr.1688.com/s/OaPpTrzR CZ0736 https://qr.1688.com/s/2Q8NXya1 CZ3050 const getShortUrl = (string) =>{ let query = string.trim().replaceAll(‘"’, ”); if(query.indexOf(‘https://qr’) >= 0){ return query.substring(query.indexOf(‘https://qr’)); } } But the above code return something like `https://qr.1688.com/s/2Q8NXya1 CZ3050` but what i wanted is something like this… Read More how to Extract Link part from a string in javascript