如果/其他声明条件

时间:2018-05-31 02:30:35

标签: javascript

我知道以下if / else语句会提示“不相等!”......

if (true) {
    alert("They are not equal!");
} else {
    alert("They are equal!");
}

但如果我用......替换我的病情会怎样?

mean    159.4604181
std 14.08847471
min 125.115372
25%   149.8761805
50% 159.13718
75% 168.4387325
max  206.164806

my data
179.810669  175.676689  184.907814  185.026245  176.046089  180.488594  162.373795  142.625153156.730606    171.185516182.506538    171.279892  157.094376  175.523239  138.663803  154.037315  146.47934   166.05497   154.187614  160.262428165.520088    159.510735  168.477242  155.714188  159.907532  154.23027   148.736519  168.688332  160.950378  150.446991154.586983    169.485733  179.650826177.456154    164.688042  158.481346  157.529823  177.155075  195.534782  185.3591    166.674973  169.619331  163.814583  171.758568  178.962212  166.57563   168.160606  175.033401  166.368645  155.475143  164.136368  129.815918  171.380379  139.883484  155.503197  144.567993  148.340202  146.3424    159.094955  138.338203  140.137421  171.319687  153.106209  165.617142  165.526573  162.551674  149.410728  169.361961  169.951523  167.23304   154.108025  147.144096  146.922226  143.736519  174.33152   178.938164  174.354897  168.984444  169.659035  159.179405  164.230553  174.717148  168.7015    168.840828  165.545853  149.285713  149.012978  156.370644  171.694534  160.497284  152.712379  162.705696  150.347458  173.261192  147.494514  175.424751  178.045708  171.828514  165.673157  160.281517  159.184944  149.384384  156.638893  173.703499  162.53994   154.150589  161.535164  162.097717  166.458252  152.737953  152.43277   164.732224  161.109459  161.410538  151.811913  144.878899  151.292107  174.201546  179.860199  156.777939  157.412254  128.193626  134.273026  165.721443  151.169197  146.080826  158.473038  156.739098  164.361488  165.708656  168.370171  131.646339  138.349174  140.834816  140.425423  141.339821  153.862488  132.983589  143.058212  157.537552  140.514938  165.444321  164.64386   152.068802  164.700546  157.977196  161.475334  152.682129  159.353088  181.302414  177.709511  174.072334  161.575821  153.542702  167.670769  177.191048  161.461784  163.927948  166.825462  147.836052  155.826508  165.665619  147.922226  150.064796  142.898941  154.046188  176.772972  162.681747  133.64357   153.721153  183.379425  170.639091  174.363014  152.349274  171.839104  154.853706  160.088364  152.339348  147.243919  167.363869  163.696533  169.445465  149.822212  188.664185  149.297455  149.38324   162.856377  167.585457  149.559311  142.964882  129.458916  160.373032  162.140373  155.924423  155.679741  154.898079  139.470657  155.763046  156.382004  149.876038  134.911156  134.708656  157.063934  143.389061  138.854088  146.451187  143.490692  170.697395  165.124054  171.297455  148.049622  156.399467  149.876228  162.300697  149.619713  143.149063  148.450333  155.154694  168.817543  169.427711  161.739861  149.329041  137.551292  162.045517  155.713234  167.576202  147.337914  156.440407  169.3153    170.732796  158.153931  148.641853  160.371506  152.678215  151.62735   144.289818  150.412636  135.979866  158.555397  144.935394  152.542038  131.922989  125.718201  160.387344  150.361771  159.63842   150.993797  141.396507  161.954765  125.115372  138.610939  156.862579  155.175972  146.390205  185.087791  164.873558  160.305084  194.200592  168.425896  168.09037   147.101822  161.535454  151.740341  162.898369  169.418549  143.773643  164.353752  175.510162  206.164806  198.906193  204.26844   173.567131  177.433823  187.072243  187.453857  180.494034  202.663326  198.192097  145.617523  148.858864  174.640137  159.404617  153.754082  150.244583  133.0271    156.841972  152.707985  172.945221  155.878998  150.713615  162.749596  151.863152  153.257278  133.326752  147.612083  151.167763  158.199638  161.290581  149.243629  155.955055

我的问题是:第二个例子中的条件是什么?
它只是说“真实” - 这是什么(需要什么是真的)?
这是否意味着它返回'true'所有的时间?

1 个答案:

答案 0 :(得分:0)

  1. 您将定义的条件,最常见的是比较。
  2. 示例:

    if(file.size > 100) { // will not be true always, it's depends of each specific file size
      alert("Your size file is bigger than permitted!");
    } else {
      alert("Your file loading...");
    }
    
    1. 在您的代码中,首先是因为您始终设置为true而始终执行条件块。在现实生活中,我们通常会对价值观和条件进行比较:
    2. 从您的代码中删除 true 放置比较条件

      示例:

      var a = "ok";
      var b = "ok";
      var c = "other text";
      
      if(a==b){ // will be true
        alert("first condition will execute a code");
      } else { 
       alert("not executed");
      }
      
      if(a==c){ // condition will be false
        alert("not executed");
      } else { 
        alert("else will execute a code...");
      }