Skip to content

Instantly share code, notes, and snippets.

@eagleflo
Created December 22, 2015 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eagleflo/e5285ee55d21aa01787c to your computer and use it in GitHub Desktop.
Save eagleflo/e5285ee55d21aa01787c to your computer and use it in GitHub Desktop.
const & Object.freeze in ES
$ babel-node
> const foo = []
'use strict'
> foo.push(1, 2, 3)
3
> foo
[ 1, 2, 3 ]
> Object.freeze(foo)
[ 1, 2, 3 ]
> foo.push(4, 5, 6)
repl:3
foo.push(4, 5, 6);
^
TypeError: Can't add property 3, object is not extensible
at repl:3:5
at Object.exports.runInThisContext (vm.js:54:17)
at _eval (/usr/local/lib/node_modules/babel/lib/_babel-node.js:86:26)
at REPLServer.replEval (/usr/local/lib/node_modules/babel/lib/_babel-node.js:169:14)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:77:13)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment