小编San*_*kar的帖子

在Javascript中从Array中删除重复的元素

我有一个带有obejcts电子邮件和Id的数组,所以我想要删除具有相似ID的重复元素.

例:

var newarray=[
    {
        Email:"test1@gmail.com",
        ID:"A"
    },
    {
        Email:"test2@gmail.com",
        ID:"B"
    },
    {
        Email:"test3@gmail.com",
        ID:"A"
    },
    {
        Email:"test4@gmail.com",
        ID:"C"
    },
    {
        Email:"test4@gmail.com",
        ID:"C"
    }
];
Run Code Online (Sandbox Code Playgroud)

现在我需要删除ID很常见的重复元素.我期待最终的数组是

var FinalArray=[
    {
        Email:"test1@gmail.com",
        ID:"A"
    },
    {
        Email:"test2@gmail.com",
        ID:"B"
    },  
    {
        Email:"test5@gmail.com",
        ID:"C"
    }
];
Run Code Online (Sandbox Code Playgroud)

javascript arrays duplicates

6
推荐指数
1
解决办法
1万
查看次数

无法从oauth2 office365 calendar API获取令牌

我无法从office365日历API获取令牌,从最近7到8个月它正在工作但突然我得到错误"期望一个数组或一个可迭代的对象,但得到[对象空]".

你们可以在这里看到我的代码

 var oauth2 = require("simple-oauth2")(ConfigOutlookCredentials);
 var scopes = ["openid","offline_access","profile",     //here 'profile' is added bz not able to getting EmailId in this function getEmailFromIdToken.
   "https://outlook.office.com/mail.read",
   "https://outlook.office.com/calendars.readwrite"
 ];

function getTokenFromCode(auth_code,callback) {
   logger.MessageQueueLog.log("info","auth_code: "+auth_code+" || redirectUri: "+redirectUri+" || scopes: "+scopes);
   oauth2.authCode.getToken({
      code: auth_code,
      redirect_uri: redirectUri,
      scope: scopes.join(" ")
   }, function(error, result) {
    logger.MessageQueueLog.log("info","error: "+util.format('%j',error.message)+" || result: "+util.format('%j',result));
    if (error) { 
        return callback(error,null);
    } else {
         var token = oauth2.accessToken.create(result); 
         return callback(null,token);
    }
  });
}
Run Code Online (Sandbox Code Playgroud)

我在重定向到我的rediredct Url并且相同的代码传递到上面的函数"getTokenFromCode"后得到代码,我仍然得到错误即" 期望数组或可迭代对象但得到[对象空] ".

请帮我弄清楚问题.提前致谢.

calendar node.js access-token oauth-2.0 office365api

5
推荐指数
1
解决办法
226
查看次数

通用链接不会重定向到应用商店

我正在尝试使用两种配置为IOS 9设备实现设置Universal Link.首先,我在服务器端完成了配置步骤:

1.创建一个未签名的apple-app-site-association-unsigned.txt文件,文件内容为

{
        "activitycontinuation": {
            "apps": [
              "9JA89QQLNQ.com.apple.wwdc"
            ]
          },
        "applinks": {
                "apps": [],
                "details": [
                    {
                        "appID":"9JA89QQLNQ.com.apple.wwdc",
                        "paths": [
                                        "*",
                                        "/"
                                ]
                    }
                ]
            }
     } 
Run Code Online (Sandbox Code Playgroud)

2.使用标记上述文件

cat apple-app-site-association-unsigned.txt | openssl smime -sign -inkey demo.key -signer demo.crt -certfile demo.pem -noattr -nodetach -outform DER> apple-app-site-association

3.然后它在签名文件上创建,即apple-app-site-association

4.将此文件移动到我的证书可用的根服务器中.

5.用node.js创建一个端点

var https = require('https');
var fs=require('fs');
var express = require('express');
var privateKey  = fs.readFileSync(home_path + 'src/Server/API/demo.key', 'utf8');
var certificate = fs.readFileSync(home_path + 'src/Server/API/demo.crt', 'utf8');
var credentials = {key: privateKey, …
Run Code Online (Sandbox Code Playgroud)

server-side node.js ios9 ios-universal-links

4
推荐指数
1
解决办法
1954
查看次数

在javascript中使用构造函数调用函数

我在javascript函数调用上有困惑,有人可以告诉下面的问题答案吗?

**Question 1:**
function A(){


}


function A(){


}

A();
Run Code Online (Sandbox Code Playgroud)

在这种情况下,哪个函数会调用?是第一个还是第二个函数?为什么?

**Question 2:**
function A(a){


}


function A(a,b){


}

A();
Run Code Online (Sandbox Code Playgroud)

在这种情况下,哪个函数会调用?是第一个还是第二个函数?为什么?

提前致谢.

javascript function-calls

1
推荐指数
1
解决办法
57
查看次数