在此函数中,(速度)是参数,零(0)在那里做什么

In this function, (speed) is the parameter, and what does the zero (0) do there?

本文关键字:在那里 什么 参数 函数 速度      更新时间:2023-09-26
this.moveRight = function(speed) {
   this.move(speed, 0);
};

我是Javascript的新手,我只是从一个游戏中获取了这段代码,我想知道这个函数发生了什么。

speed是您使用function()创建的moveRight函数的参数。它在this内部调用 move 函数,参数为 speed0

所以moveRight就像一个部分,它为move(0)提供默认参数并保留参数speed

0可能代表正确的方向。