请多多包涵,我是编码的新手。我正在尝试测试Web服务,并且遇到了Java脚本数组,我需要从10个字段中获取2个字段以进行进一步测试。如果有人可以帮助我,我将不胜感激?
答案 0 :(得分:0)
试试看!
<script>
let colors = ["Red", "Green", "Blue"];
alert(colors[2]);
</script>
或更通用:
<script>
let colors = ["Red", "Green", "Blue"];
//Output: Blue (Note that arrays starts with 0)
PrintArrayValue(colors, 2);
function PrintArrayValue(array, index){
alert(array[index]);
}
</script>