Skip to content

Instantly share code, notes, and snippets.

@teramako
Last active October 26, 2017 15:04
Show Gist options
  • Save teramako/6317d057902b91c0dc1a to your computer and use it in GitHub Desktop.
Save teramako/6317d057902b91c0dc1a to your computer and use it in GitHub Desktop.

ECMAScript6th Quiz Answer

Answer of ES6 Quiz

A.1

  • 2 "func"

see: 9.2.12 SetFunctionName, 12.14.4 Runtime Semantics of AssignmentExpression

A.2

  • 2 3

DOLPHIN.length is 2, however SpreadElement (String iterator) takes care of surrogate pair

A.3

  • 3 3

Object.assign puts all own properties without non-enumerable. And Object.getOwnPropertySymbols gets all Symbol keys whether enumerable or not.

A.4

  • 2 [true, false, false]

__proto__ magic property affects *non-*ComputedPropertyName.

See: B.3.1 __proto__ Property Names in Object Initializers

A.5

  • 1 "A"

ArrowFunction resolves to arguments binding in a lexically same as this, super and new.target. See: 14.2.15 Runtime Semantics: Evaluation of ArrowFunction

A.6

  • 3 "undefined"

{ foo: "BAR" } is not parsed as ObjectLiteral, but as Block and LabelledStatement. And that doesn't contains ReturnStatement, so return value is undefined.

A.7

  • 3 [true, true, false]

String.raw escapes EscapeSequence

A.8

  • 1 "outside"

MethodDefinition set the function name but not binds. See: 14.3.10 Runtime Sematics: ProeprtyDefinitionEvaluation

A.9

  • 4 thrown SyntaxError

foo: function(){ return "FOO" } is parsed as LabelledStatement, but missing function name.

A.10

  • 4 thrown SyntaxError

See: B.3.2 Labelled Function Declarations

A.11

  • 5 thrown TypeError

function of MethodDefinition doesn't have [[Construct]] internal method.

A.12

  • 1 1

RestParameter is appeared (not-simpleParameterList), ArgumentsObject is created as UnmappedArgumentsObject.

See: 9.2.13 FunctionDeclarationInstantiation, 9.4.4.6 CreateUnmappedArgumentsObject

A.13

  • 3 [false, false, true, true, true]

sparse array vs. dense array.

A.14

  • 3 [1]

Array.prototype.some validates whether the key is present or not, but Array.prototype.find doesn't.

A.15

  • 3 4

See: https://twitter.com/rauschma/status/568063153755594752

A.16

  • 2 [1, 2]

See: isNaN, Number.isNaN

A.17

  • 1 2

Array.from likes iterator rather than length property.

See: Array.from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment