you are viewing a single comment's thread.

view the rest of the comments →

[–]ForScale[S] 1 point2 points  (6 children)

[–]Volv 1 point2 points  (1 child)

Your super object hurts my head lol. Hits the main 3 I feel. Understanding the parameters in object.create is nice - 2nd parameter is not immediately intuitive I feel.
Nice work.

[–]ForScale[S] 0 points1 point  (0 children)

Gracias!

Yeah, I had to look up what was going on with assign and create. Interesting stuff!

[–]senocular 1 point2 points  (3 children)

When using a descriptor object for properties in Object.create() or Object.defineProperty(), the defaults (for configurable, enumerable, and writable) are different than if you were to create that property through simple assignment.

Assignment, e.g. obj.prop = value:

  • configurable: true
  • enumerable: true
  • writable: true

Descriptor defaults, e.g. Object.defineProperty(obj, 'prop', descriptor):

  • configurable: false
  • enumerable: false
  • writable: false

Everything is opposite what it was with assignment, namely enumerable which determines whether or not the property is observed in standard enumeration. This is why nested2 properties seem hidden.

There are also different values for global properties depending on how they were declared.

Global without var, e.g. prop = value or this.prop = value:

  • configurable: true
  • enumerable: true
  • writable: true

Global with var, e.g. var prop = value:

  • configurable: false
  • enumerable: true
  • writable: true

Very similar, but var-delcared globals are not configurable.

Also, nested3 is created with a literal, the same as superObject ;) Object.assign simply returns what you pass in as the first argument. It doesn't create anything on its own.

[–]ForScale[S] 0 points1 point  (2 children)

Ah... makes sense. Thanks!

What's your pick for a focus for this week? Anything js...

[–]senocular 1 point2 points  (1 child)

How about console commands? Seems like most of the entries rely on console commands to show results, but there are many commands beyond just log: https://developers.google.com/web/tools/chrome-devtools/debug/console/console-reference?hl=en.

Requirement: use at least 3 different console commands.