我想检查用户是否给了脚本任何参数,如果是这种情况,脚本应该关闭。
if [ $@ = "" ]; then
exit
fi
无效。
答案 0 :(得分:1)
你可以这样试试,
<script type="text/javasctipt">var arr1 = [{"id":2,"student_name":"LSa"},{"id":3,"student_name":"Liu Sa"},{"id":77,"student_name":"Liu Sa"}];
var arr2 = [{"id":2,"student_name":"A"},{"id":3,"student_name":"L"},{"id":4,"student_name":"B"},{"id":55,"student_name":"C"},{"id":25,"student_name":"D"},{"id":23,"student_name":"E"},{"id":89,"student_name":"F"}];
arr1.forEach(function(value1) {
arr2.forEach(function(value2) {
if (value1.id === value2.id ) {
document.getElementById('list').innerHTML += (value2.student_name + " -- true, <br/>");
}else{
document.getElementById('list').innerHTML += (value2.student_name +" -- false, <br/>");
}
});
});
//Expected result : A-true,L-true,B-false,C-false,D-false,E-false,F-false</script>
<div id="list"></div>