Node.js 8.3.0 has been released

New version of popular JavaScript framework is out now, with a TurboFan enabled by default
Sergey Siminskiy's picture
Sergey Siminskiy
11 August

Node.js team has recently released version 8.3.0

What's inside?

The V8 engine has been upgraded to version 6.0, which has a significantly changed performance profile.

  • DNS
    • Independent DNS resolver instances are supported now, with support for cancelling the corresponding requests.
  • N-API
    • Multiple N-API functions for error handling have been changed to support assigning error codes. 
  • REPL
    • Autocompletion support for require() has been improved. 
  • Utilities
    • The WHATWG Encoding Standard (TextDecoder and TextEncoder) has been implemented as an experimental feature.

What is Node.js TurboFan? 

TurboFan is one of V8's optimizing compilers leveraging a concept called "Sea of Nodes". TurboFan combines a cutting-edge intermediate representation with a multi-layered translation and optimization pipeline to generate better quality machine code than what was previously possible with the CrankShaft JIT. Optimizations in TurboFan are more numerous, more sophisticated, and more thoroughly applied than in CrankShaft, enabling fluid code motion, control flow optimizations, and precise numerical range analysis, all of which were more previously unattainable.

Learn more about new version of Node.js and TurboFan.

How to set "check" to a checkbox in jQuery?

Small jQuery tutorial on common issue with code examples
Sergey Siminskiy's picture
Sergey Siminskiy
21 August

Let's consider three options for different versions of jQuery.

jQuery 1.6+

Use the new .prop() method:

$('.myCheckbox').prop('checked', true);
$('.myCheckbox').prop('checked', false);

jQuery 1.5.x and below

The .prop() method is not available, so you need to use .attr().

$('.myCheckbox').attr('checked', true);
$('.myCheckbox').attr('checked', false);

Note that this is the approach used by jQuery's unit tests prior to version 1.6 and is preferable to using

$('.myCheckbox').removeAttr('checked');

since the latter will, if the box was initially checked, change the behaviour of a call to .reset() on any form that contains it - a subtle but probably unwelcome behaviour change.

Any version of jQuery

If you're working with just one element, you can always just modify the HTMLInputElement's .checked property:

$('.myCheckbox')[0].checked = true;
$('.myCheckbox')[0].checked = false;

The benefit to using the .prop() and .attr() methods instead of this is that they will operate on all matched elements.