I was expecting something like "154, 544 true" but this is not working.
<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);
I assume that you want to check a variable is an Array or not?
If yes, you can use this
Array.isArray(<variable_name>); // returns `true` if the variable is an Array, `false` otherwise
Complete reference: MDN
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.