gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
js 判断10 是否在 [11,12,13] 内
- User
js 判断10 是否在 [11,12,13] 内
- Assistant
可以使用 JavaScript 的 includes() 方法来判断一个元素是否在数组中。
示例代码:
const arr = [11, 12, 13]; const isContained = arr.includes(10); console.log(isContained); // false这段代码中,我们先定义了一个数组 arr,然后使用 includes() 方法来判断数字 10 是否在数组中。由于数组中没有数字 10,所以 isContained 变量的值为 false。