Node: Array.includes() is not working

Created on 15 Mar 2016  路  3Comments  路  Source: nodejs/node

> [1].includes(1)
TypeError: [1].includes is not a function
    at repl:1:5
    at REPLServer.defaultEval (repl.js:260:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:429:12)
    at emitOne (events.js:95:20)
    at REPLServer.emit (events.js:182:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
    at REPLServer.Interface._ttyWrite (readline.js:827:14)
  • Version: 5.8.0
  • Platform: Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64
V8 Engine

Most helpful comment

This is currently hidden behind a harmony flag:

$ node --harmony_array_includes
> [1, 2, 3].includes(2);
true

All 3 comments

This is currently hidden behind a harmony flag:

$ node --harmony_array_includes
> [1, 2, 3].includes(2);
true

Works without a flag in master with V8 4.9:

> [1].includes(1)
true

Like @jbergstroem says, in node.js v5, it's behind the --harmony_array_includes flag. Closing, not a bug.

Thanks guys. I didn't know about Harmony flags. I reported this after I'd searched the docs for "includes" and couldn't find an answer.

Was this page helpful?
0 / 5 - 0 ratings