p5 理解函数参数

p5 understanding an function parameter

p5 Site 上给出的示例中使用了一个参数(我认为这是正确的术语)'function(other)',我不太明白。非常感谢您需要上面 link 中提供的完整代码。任何愿意解释的人将不胜感激。

Particle.prototype.display = function(other) {
  stroke(0, this.lifespan);
  fill(0, this.lifespan/2);    
  ellipse(this.position.x,this.position.y, 8, 8);    
  // If we need to draw a line
  if (other) {
    line(this.position.x, this.position.y, other.position.x, other.position.y);
  }
}

一个函数可以接受一个参数。参数写在括号里。在这个例子中,参数是 other。在上面的例子中。 "other" 是另一个对象。例如。 Particle.prototype.display(someobject);

我希望这是可以理解的。

var div = document.getElementById("test");

test(true);
test(false);

function test(parameter){
  if(parameter){
    div.innerHTML += "Hello"
    }else{
    div.innerHTML += " World!"
    }
}
<div id="test"></div>