我原本期望像“ 154,544 true”之类的东西,但这不起作用。
<p id="demo"></p>
<script>
var n = [154, 45, 100, 544, 75], txt = "";
var nFil = n.filter((value) => value > 100);
txt = nFil.join(", ") + "<br>" + nFil instanceof Array;
document.getElementById("demo").innerHTML = txt;
</script>
最佳答案
括号需要像:
txt = nFil.join(", ") + "<br>" + (nFil instanceof Array);
关于javascript - arrayname instanceof Array;不能按预期工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59743856/