当我使用void printConcatLine(char chunks[][20]) {
for(int x = 0; x < sizeof(chunks); ++x) {
if(x < (sizeof(chunks) - 1)) {
Serial.print(chunks[x]);
} else {
Serial.println(chunks[x]);
}
}
}
char chunks[][20] = {
"{",
"255"
"}"
};
printConcatLine((char*[]){ "{", "255", "}" });
````````````````````````
时,它会给我带来价值,但不会将其放入创建的对象中
这是我的代码:
document.getElementById()
如果您能帮助我解决问题,我将不胜感激
答案 0 :(得分:0)
您没有将person
对象与people Array正确链接。看来这就是您尝试使用People[counter++] = person;
正确的方法是:
<script>
var People = []
var counter = 0;
function Add() {
var fname = document.getElementById('Fname').value;
var lname = document.getElementById('Lname').value;
var age = document.getElementById('age').value;
var person = {
FirstName: fname,
LastName: lname,
Age: age
};
People.push(person)
console.log(People)
return People
}
</script>
如果您对第一种方法不满意,也可以这样做。
var People = new Array();
var counter = 0;
function Add() {
var fname = document.getElementById('Fname').value;
var lname = document.getElementById('Lname').value;
var age = document.getElementById('age').value;
var person = {
FirstName: fname,
LastName: lname,
Age: age
};
People[counter] = person;
++counter
console.log(People)
}