How to stop a function

A simple return statement will ‘stop’ or return the function; in precise terms, it ‘returns’ function execution to the point at which the function was called – the function is terminated without further action. That means you could have a number of places throughout your function where it might return. Like this:

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