Javascript 将变量推送到对象内的数组上?
我试图将数据推送到对象中的student tags数组的末尾,我想知道如何才能做到这一点Javascript 将变量推送到对象内的数组上?,javascript,arrays,json,google-apps-script,javascript-objects,Javascript,Arrays,Json,Google Apps Script,Javascript Objects,我试图将数据推送到对象中的student tags数组的末尾,我想知道如何才能做到这一点 var tags = "2019 Student" { "first_name": "Thomas", "last_name": "Lee", "email": "tjhunt03@gmail.com", "student_tags": ["2020 Student"] } 使用推送式学生标签: 您只需转到student_tags属性并按下标记即可 student.stude
var tags = "2019 Student"
{
"first_name": "Thomas",
"last_name": "Lee",
"email": "tjhunt03@gmail.com",
"student_tags":
["2020 Student"]
}
使用推送式学生标签:
您只需转到student_tags属性并按下标记即可
student.student_tags.push(tags);
使用推送将项添加到数组中
让tags=2019学生
设obj={
名字:托马斯,
姓氏:李,
电邮:tjhunt03@gmail.com,
学生标签:[2020学生]
};
obj.student_tags.pushtags;
console.logobj;
var tags = "2019 Student"
var student = {
"first_name": "Thomas",
"last_name": "Lee",
"email": "tjhunt03@gmail.com",
"student_tags":
["2020 Student"]
}
student.student_tags.push(tags);