The month at 2ality: February 2012

To be notified of updates of existing content on 2ality, you have to follow @rauschma on Twitter. Not everyone is willing or able to do that. Therefore, this new monthly column collects that information and makes it available as a blog post. It also reports on current topics that were previously covered on 2ality.

Current topics previously covered on 2ality

  • Constructor property: David Herman asks:
    Lazytwitter: is it bad style to write C.prototype = { ... }; without ensuring that C.prototype.constructor === C?
    David Flanagan answers:
    I'd set the constructor property for classes in a public library, but might skip it elsewhere.
    Normally, all prototypes C.prototype are already set up so that Herman’s equation holds. However, with subtyping, you have to replace the prototype and then must set the constructor property yourself. But normally, you should use an inheritance library that does handles this task for you. See: “What’s up with the “constructor” property in JavaScript?
  • “Can anyone explain these bizarre Javascript behaviours mentioned in the ‘Wat’ talk for CodeMash 2012?” [question on Stack Overflow]
  • CSS4 parent selectors: In a project, I tried to use CSS to highlight the background of a checkbox item if the checkbox is checked. Tricky – I ended up using JavaScript to assist CSS. But it will be trivial once we have CSS4 parent selectors.

Updates of existing posts

Complementary material for existing posts