是个 ; JavaScript中强制使用(分号)?

时间:2018-05-13 11:46:54

标签: javascript

我是JavaScript新手,对const portNumber = 8080; const app = express(); 的角色感到很困惑。我有以下代码,运行顺利。他们都没有遇到错误。

代码1:

const portNumber = 8080
const app = express()

代码2:

import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
import org.apache.commons.lang3.tuple.Pair;
import org.joda.time.LocalDateTime;

public final class TimeSeries {

    private final NavigableMap<LocalDateTime, Double> series = new ConcurrentSkipListMap<>();

    public TimeSeries(Map<LocalDateTime, Double> m) {
        series.putAll(m);
    }

    public Double get(LocalDateTime t){
        return series.get(t);
    }

    public Pair<Entry<LocalDateTime, Double>, Entry<LocalDateTime, Double>> lrPoints(LocalDateTime t) {
        if (series.isEmpty() || t.isBefore(series.firstKey()) || t.isAfter(series.lastKey()))
            throw new IllegalArgumentException("t outside of time series bounds");
        Entry<LocalDateTime, Double> l = series.floorEntry(t);
        Entry<LocalDateTime, Double> r = series.ceilingEntry(t);
        return Pair.of(l,r);
    }
}

因此,似乎没有必要使用分号。那么,如果我更愿意专注于代码2中的其他内容,为什么还要像代码1那样烦恼呢?在代码1中使用分号是否有任何意义?

0 个答案:

没有答案