Drew
Drew

Reputation: 827

Simple JS Arrow Function: Missing Parenthesis After Argument List: Why?

This simple javascript arrow function results in a parser error. The syntax seems consistent with all the examples I've seen. What is the syntax error and how do I correct it?

var things = [];
things.push("a");
var containsA = things.some(t => t === "a");

The error: Uncaught SyntaxError: missing ) after argument list

Upvotes: 0

Views: 2572

Answers (2)

PM 77-1
PM 77-1

Reputation: 13344

Currently Arrow Functions are supported by FireFox only.

From MDN:

Browser Compatibility for Arrow Functions

Upvotes: 1

Oriol
Oriol

Reputation: 288520

Your code produces a valid arrow function:

t => t === "a"

However, arrow functions are an experimental technology, part of the ECMAScript 6 proposal, which currently is still a draft. Therefore, not all browsers have implemented them yet.

Among the major ones, only Firefox has. If you attempt to use them on Chrome, you will get an error.

Upvotes: 1

Related Questions