Skip to content
a tc39 ECMAScript proposal to use variable placeholders similar to scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

ECMAScript Placeholder Syntax

This proposal is for the new operator ?. This operator is syntactic sugar for creating an anonymous function which applies its arguments to the expression given.


calling a prototype method:

const lowercase = ['a','b','c']

// with placeholder syntax
const uppercase =
// without placeholder syntax
const uppercase => string.toUpperCase())

passing to another expression:

const phrases = ['hello', 'world']

// with placeholder syntax
// transforms into
phrases.forEach(phrase => console.log(phrase))

multiple arguments:

const numbers = [1,3,10,5]

// with placeholder syntax
const sum = numbers.reduce(? + ?)
// without placeholder syntax
const sum = numbers.reduce((acc, val) => acc + val)


This proposal is simple to understand, and will cut down lines of code that do not add any more information to the user. In addition to that, this cuts down on naming variables, which can become a pain point when larger codebases need every variable to be explicit.

This syntax already exists in Scala


The ? operator can only be used in the same scope that arguments are passed to a function.


  • Can type libraries like Flow and Typescript handle this syntax, which has to be equivalent to un-typed anonymous functions?
  • does this clash with the multiply operator?
You can’t perform that action at this time.