在JavaScript中,什么是aaaa?bbbb(查询点)怎么办



这似乎是不可能搜索的事情之一,因为当前所有的搜索引擎都拒绝进行文字搜索。因此,如果能得到一个明确的答案,那就太好了。

如果我有一个JavaScript语句,比如:

const clientRealIpAddress =
//get ip from behind a nginx proxy or proxy using nginx's 'x-real-ip header
socket.request?.headers['x-real-ip']
//get ip from behind a general proxy
|| socket.request?.headers['x-forwarded-for']?.split(',').shift() //if more thatn one x-fowared-for the left-most is the original client. Others after are successive proxys that passed the request adding to the IP addres list all the way back to the first proxy.
//get ip from socket.request that returns the reference to the request that originated the underlying engine.io Client
|| socket.request?.connection?.remoteAddress
// get ip from socket.handshake that is a object that contains handshake details
|| socket.handshake?.address

?.做什么?

可选的链接运算符(?.(使您能够读取位于连接对象链深处的属性的值,而无需检查链中的每个引用是否有效。

检查此项:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

最新更新