写一段javascript使用contains方法判断A是否在params中的代码
时间: 2024-05-03 10:22:05 浏览: 67
JS判断字符串包含的方法
Certainly, here is a sample code that uses the `contains` method in JavaScript to check if `A` is present in `params`:
```
let params = ["B", "C", "A", "D"];
if (params.contains("A")) {
console.log("A exists in params");
} else {
console.log("A does not exist in params");
}
```
In this code, we first define an array called `params` that contains several elements. We then use the `contains` method to check if the value "A" is included in the `params` array. If it is present, the code will log "A exists in params". Otherwise, the code will log "A does not exist in params".
阅读全文