alert a variable value

A couple of things: You can’t use new as a variable name, it’s a reserved word. On input elements, you can just use the value property directly, you don’t have to go through getAttribute. The attribute is “reflected” as a property. Same for name. So:

How can I group data with an Angular filter?

You can use groupBy of angular.filter module.so you can do something like this: JS: HTML: RESULT:Group name: alpha* player: GeneGroup name: beta* player: George* player: PaulaGroup name: gamma* player: Steve* player: Scruath UPDATE: jsbin Remember the basic requirements to use angular.filter, specifically note you must add it to your module’s dependencies: (1) You can install angular-filter using 4 different methods: … Read more

How do I check whether an array contains a string in TypeScript?

The same as in JavaScript, using Array.prototype.indexOf(): Or using ECMAScript 2016 Array.prototype.includes(): Note that you could also use methods like showed by @Nitzan to find a string. However you wouldn’t usually do that for a string array, but rather for an array of objects. There those methods were more sensible. For example Reference Array.find() Array.some() Array.filter()

Does JavaScript support array/list comprehensions like Python?

Update: Array comprehensions were removed from the standard. Quoting MDN: The array comprehensions syntax is non-standard and removed starting with Firefox 58. For future-facing usages, consider using Array.prototype.map, Array.prototype.filter, arrow functions, and spread syntax. See this answer for an example with Array.prototype.map: let emails = people.map(({ email }) => email); Original answer: Yes, JavaScript will support array comprehensions in the upcoming EcmaScript … Read more

Change CSS of class in Javascript?

You can do that — actually change style rules related to a class — using the styleSheets array (MDN link), but frankly you’re probably better off (as changelog said) having a separate style that defines the display: none and then removing that style from elements when you want them no longer hidden.