javascript 字节

    技术2022-07-11  141

    javascript 字节

    Whenever you work with JavaScript code, it's as though there's always a shorter way to code something.  You thought that a code set was basic until you found out that something was basic...er.  One of those code shortcuts can be found with conditions, specifically short if clauses.

    每当您使用JavaScript代码时,似乎总会有一种较短的方法来编写代码。 您以为代码集是基本的,直到您发现某些东西是基本的...呃。 可以使用条件找到这些代码快捷方式之一,特别是if子句。

    A typical short if clause would look something like this:

    典型的short if子句如下所示:

    if(callback) { callback(); }

    Oddly enough this conditional can be made shorter:

    奇怪的是,该条件可以缩短:

    callback && callback();

    The && is less code than the if(){}; of course only by a few characters but does the same job. You could argue that readability suffers but that's up to individual developers.

    &&的代码少于if(){} ; 当然只有几个字符,但可以完成相同的工作。 您可能会争辩说可读性会受到影响,但这取决于单个开发人员。

    翻译自: https://davidwalsh.name/javascript-conditionals

    javascript 字节

    相关资源:jdk-8u281-windows-x64.exe
    Processed: 0.013, SQL: 9