var old_response = ["a,b,c","x,y,z","e,f,g"]
new_response = ["a,b,c,x,y,z,e,f,g"]
目前我收到的是old_response
,而不是我需要的new_response
答案 0 :(得分:2)
只需使用Array#join
方法加入元素并放入一个新数组。
var old_response = ["a,b,c","x,y,z","e,f,g"] ;
var new_response = [old_response.join()];
console.log(new_response);
答案 1 :(得分:2)
old_response = ["a,b,c","x,y,z","e,f,g"]
console.log([old_response.join()])
答案 2 :(得分:0)
您可以将数组转换为字符串:
firebase.auth().onAuthStateChanged(function(user){
if(user){
console.log(user);
console.log('logged in');
signInButton.style.display = "none";
signOutButton.removeAttribute('hidden');
messaging.getToken()
.then(function(currentToken) {
console.log(currentToken);
})
.catch(function(err) {
console.log('Unable to retrieve refreshed token ', err);
});
messaging.onTokenRefresh(function() {
messaging.getToken()
.then(function(refreshedToken) {
console.log(refreshedToken);
console.log('Token refreshed.');
})
.catch(function(err) {
console.log('Unable to retrieve refreshed token ', err);
});
});
messaging.onMessage(function(payload){
console.log('onMessage: ', payload);
})
}else{
console.log('not logged in');
}
});