Strawman: Tuples

Michał Wadas michalwadas at
Wed Sep 10 10:57:35 PDT 2014

Should we have new type - tuples?

My proposal:
- Tuples are immutable.
var wow = new Tuple('my', 'little', 'Cthulhu');
wow[2] = 'Nyarlathotep'; // throws in strict mode, silently fails in sloppy mode
- Tuples are primitive type. Comparison between tuples is based on
identity of elements, not identity of tuples
new Tuple(Object, Function, null, NaN) === new Tuple(Object, Function,
null, NaN); // true
- typeof new Tuple(); // 'tuple'
- Tuple(['wow', 'a', 'b']) = new Tuple('wow', 'a', 'b'); // true
- Tuple.prototype.add = function add() {
return new Tuple(...this, ...arguments);

- tuples are very memory efficient
- comparision based on identity of elements is required in many cases
- ???

More information about the es-discuss mailing list