Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

js includes 字符串

作者:翔龙天下   发布日期:2025-10-05   浏览:7

// 使用 includes 方法检查字符串中是否包含指定的子字符串

const str = "Hello, world!";
const substr = "world";

if (str.includes(substr)) {
  console.log("字符串中包含 'world'");
} else {
  console.log("字符串中不包含 'world'");
}

// includes 方法返回一个布尔值,表示指定的子字符串是否存在。
// 它区分大小写,因此 "World" 和 "world" 被认为是不同的字符串。

// 示例:检查大小写敏感性
console.log(str.includes("World")); // false
console.log(str.includes("world")); // true

上一篇:js 整数正则

下一篇:js string转float

大家都在看

js 数组对象排序

js 数组删掉第一个值

js fill

js 数组连接

js json数组

js 数组复制

js 复制数组

js 数组拷贝

js 对象数组合并

js 对象转数组

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站