小编Dan*_*n K的帖子

何时使用分号

特别是在JavaScript中,何时使用分号,何时使用分号.

这是一段代码示例;

function Drawable() {
   this.init = function(x, y) {
      this.x = x;
      this.y = y;
   }

   this.speed = 0;
   this.canvasWidth = 0;
   this.canvasHeight = 0;

   this.draw = function() {
   };
}
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我为什么

this.init = function(x,y) {}
Run Code Online (Sandbox Code Playgroud)

但是,并不以分号结尾

this.draw = function(){};
Run Code Online (Sandbox Code Playgroud)

在上面的代码片段中以分号结尾?

javascript

2
推荐指数
1
解决办法
168
查看次数

标签 统计

javascript ×1