Unary & Double Bang !! Casting
Video
JavaScript Notes
JavaScript
// double-bang.js
// Casting to Boolean with the !!
// Casting to Number with unary +
// unary binary ternary
log = console.log;
let num = 12;
// if ( ! num ) ;
let bool = !!num; // flips from number, to falsey, to true
let str = "14";
let fourteen = +str; // converts from string into an actual number
Feedback
Submit and view feedback