Counting the occurrences / frequency of array elements

In Javascript, I’m trying to take an initial array of number values and count the elements inside it. Ideally, the result would be two new arrays, the first specifying each unique element, and the second containing the number of times each element occurs. However, I’m open to suggestions on the format of the output. For … Read more

How may I reference the script tag that loaded the currently-executing script?

How can I reference the script element that loaded the javascript that is currently running? Here’s the situation. I have a “master” script being loaded high in the page, first thing under the HEAD tag. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”> <head> <script type=”text/javascript” src=”https://stackoverflow.com/questions/403967/scripts.js”></script> There is a script … Read more

How can I loop through enum values for display in radio buttons? [duplicate]

This question already has answers here: How to get names of enum entries? (41 answers) Closed 5 years ago. What is the proper way to loop through literals of an enum in TypeScript? (I am currently using TypeScript 1.8.1.) I’ve got the following enum: export enum MotifIntervention { Intrusion, Identification, AbsenceTest, Autre } export class … Read more