【发布时间】:2020-02-22 14:44:57
【问题描述】:
JavaScript 新手!如果我想编辑和更新具有预先存在值的对象怎么办?
array [];
// this function is for pre-existed value
function object1 ( mytext ) {
this.text = mytext
}
var usertext = new object ("my text to edit");
memArray.push (usertext);
console.log (usertext)
如何编辑/更新提示值?
function object2(){
var text
this.getData = function(){
return{
text: this.text
}
}
this.setData = function (){
this.text = prompt ("Type anything");
}
return this.setData();
}
var user = new addUserObject;
memArray.push(user.getData());
console.log(memArray);
【问题讨论】: