2017/12/24 - 2018/1/19

// 这个还是有意思的:
// An object can only be converted if it has a key valueOf and it's function returns any of the above types.
+{
  valueOf: function(){
    return '0xFF'
  }
}
//returns 255
  • ★ JS things I never knew existed

    • 这里作者讲的还都是挺有意思的点。
    • Label Statements
        loop1: // labeling "loop1" 
        for (let i = 0; i < 3; i++) { // "loop1"
            loop2: // labeling "loop2"
            for (let j = 0; j < 3; j++) { // "loop2"
                if (i === 1) {
                    continue loop1; // continues upper "loop1"
                    // break loop1; // breaks out of upper "loop1"
                }
            console.log(`i = ${i}, j = ${j}`);
            }
        }
        
    
    • Comma Operator
    y = false, true; // returns true in console
    console.log(y); // false (left-most)
    
    z = (false, true); // returns true in console
    console.log(z); // true (right-most)
    
    • Pipeline Operator: 管道操作符最近在 TC39 的提议中,不知是否会加入特性中,全看大佬们的啊。
      const square = (n) => n * n;
      const increment = (n) => n + 1;
      
      // without pipeline operator
      square(increment(square(2))); // 25
      
      // with pipeline operator
      2 |> square |> increment |> square; // 25
      
      
  • HTML5.2 New Dialog Element

    • 话说还是增加了些东西的,都还没有看。2333333
    • 原生模态层算是解决了一个大问题的。MDN 参考
    <dialog open>
        Native dialog box!
    </dialog>