相当于
in_array
在javascript中是
includes
例如,如果要从
Node.js
到
ejs
文件,您可以这样做:
res.render('index', {numbers : [1, 23, 44]});
然后在里面
ejs公司
您可以使用该方法
包括
,例如:
<body>
<% if(numbers.includes(44)){ %>
<h1>44 exists</h1>
<% } else{ %>
<h1>44 not exists</h1>
<% } %>
</body>
也可以使用方法
indexOf
,返回数组中给定值的索引。