Weekly 00001011

Weekly 不發出來都沒有動力更新, 都變成 Monthly 了???。 每一個連接下都是本身的拙見,望各位大佬多多指教。 博客連接

2017/12/24 - 2018/1/19javascript

// 這個仍是有意思的:
// 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>
相關文章
相關標籤/搜索