我有这个数组
var a = [5] , count = 5;
Run Code Online (Sandbox Code Playgroud)
我想知道这个数组(a)上缺少的数字,结果必须是
1,2,3,4
我只是尝试这个但失败了
var missing = [];
for ( var j = 0; j < a.length; j++ ) {
for ( var i = 1; i <= count; i++ ) {
if (a[j] != i) {
missing.push( i );
}
}
}
Run Code Online (Sandbox Code Playgroud)
我马上打电话给它
1,2,3,4
为(a)数组添加一些值
a = [2,3,4,5]
Run Code Online (Sandbox Code Playgroud)
它给我这个
[1,3,4,5,1,2,4,5,1,2,3,5,1,2,3,4]
我该怎么解决它找到计数值的缺失数字
注意*找到计数值的缺失数字
我想使用 socket.io 在节点服务器中获取 cookie 值
所以每次套接字向服务器发送消息时,我都会检查 cookie 的值
(我不想要会话 cookie)只有在 express 我得到 cookie
router.get('/', function(req, res, next) {
var cookie_id = req.cookies.userIDf;
console.log(cookie_id);
res.render('index', { title: 'Express' });
});
Run Code Online (Sandbox Code Playgroud)
它在这里工作,但使用 socket.io 我无法获得 cookie 任何解决方案?
io.sockets.on('connection', function (socket) {
var cookief =socket.handshake.headers['cookie'];
console.log(cookief); // its give me session id not the cookies
});
Run Code Online (Sandbox Code Playgroud)