diff --git a/lib/dgram.js b/lib/dgram.js index a89a61cb06df96..97c2de5fc47ef7 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -134,7 +134,7 @@ function replaceHandle(self, newHandle) { self._handle = newHandle; } -Socket.prototype.bind = function(port_ /*, address, callback*/) { +Socket.prototype.bind = function(port_, address_ /*, callback*/) { let port = port_; this._healthCheck(); @@ -144,7 +144,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) { this._bindState = BIND_STATE_BINDING; - if (typeof arguments[arguments.length - 1] === 'function') + if (arguments.length && typeof arguments[arguments.length - 1] === 'function') this.once('listening', arguments[arguments.length - 1]); if (port instanceof UDP) { @@ -161,7 +161,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) { exclusive = !!port.exclusive; port = port.port; } else { - address = typeof arguments[1] === 'function' ? '' : arguments[1]; + address = typeof address_ === 'function' ? '' : address_; exclusive = false; }