V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
Cbdy

今天看 js 的 proposal-class-fields 提案的一个 issue,笑死了

  •  
  •   Cbdy · Aug 15, 2018 · 2920 views
    This topic created in 2816 days ago, the information mentioned may be changed or developed.

    关于 js 私有属性的新语法

    class Counter extends HTMLElement {
      #x = 0;
    
      clicked() {
        this.#x++;
        window.requestAnimationFrame(this.render.bind(this));
      }
    
      constructor() {
        super();
        this.onclick = this.clicked.bind(this);
      }
    
      connectedCallback() { this.render(); }
    
      render() {
        this.textContent = this.#x.toString();
      }
    }
    window.customElements.define('num-counter', Counter);
    

    下面的评论😄

                       __________\
                      /          \\\
                     /    REST    \\\
                    /      IN      \\\
                   /     PEACE      \\\
                  /                  \\\
                  |       es         |\
                  |                  |\
                  |   killed by a    |\
                  |  private-fields  |\
                  |       2018       |\
                 *|     *  *  *      | *\
         ________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______
    

    传送门

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1003 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:14 · PVG 02:14 · LAX 11:14 · JFK 14:14
    ♥ Do have faith in what you're doing.