Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc
Example:
Bàn luận
string.includes(searchvalue, start)0
string.includes(searchvalue, start)1
string.includes(searchvalue, start)2string.includes(searchvalue, start)3
string.includes(searchvalue, start)4string.includes(searchvalue, start)5string.includes(searchvalue, start)6string.includes(searchvalue, start)7
string.includes(searchvalue, start)4string.includes(searchvalue, start)9
Dưới đây là ví dụ về chuỗi bao gồm () phương thức. & Nbsp; & nbsp;
JavaScript
Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true0Input: Welcome to GeeksforGeeks. Output: false1string.includes(searchvalue, start)6Input: Welcome to GeeksforGeeks. Output: false3
string.includes(searchvalue, start)4Input: Welcome to GeeksforGeeks. Output: false5
string.includes(searchvalue, start)2Input: Welcome to GeeksforGeeks. Output: false7
Input: Welcome to GeeksforGeeks. Output: false8
Output:
trueInput : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true2Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true3Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true4
Note: The includes() method is case sensitive i.e, it will treat the Uppercase characters and Lowercase characters differently.
Syntax:
Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true7Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true8Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true9
- Trong JavaScript, bao gồm () phương thức xác định xem một chuỗi có chứa các ký tự đã cho trong đó hay không. nhạy cảm, nó sẽ xử lý các ký tự chữ hoa và các ký tự thường khác nhau.syntax: & nbsp; & nbsp; It is the string in which the search will take place.
- Tham số được sử dụng: & nbsp; & nbsp; This is the position from
where the search will be processed
(although this parameter is not necessary if this is not mentioned the search will begin from the start of the string). - Giá trị tìm kiếm: Đó là chuỗi mà tìm kiếm sẽ diễn ra.
Examples:
Bắt đầu: Đây là vị trí từ nơi tìm kiếm sẽ được xử lý & nbsp; (mặc dù tham số này là không cần thiết nếu điều này không được đề cập & nbsp; tìm kiếm sẽ bắt đầu từ đầu chuỗi).
Trả về một sự thật Boolean cho thấy sự hiện diện hoặc nó trả về sai cho thấy sự vắng mặt. Even in this case the second parameter is not defined, so the search will take place from the starting index. But as this method is case sensitive it will treat the two strings differently, hence returning a boolean false.
Since it is case sensitive.
Codes for the above function are provided below.
Code 1:
Bàn luận
string.includes(searchvalue, start)0
string.includes(searchvalue, start)1
string.includes(searchvalue, start)2string.includes(searchvalue, start)3
string.includes(searchvalue, start)4string.includes(searchvalue, start)5string.includes(searchvalue, start)6string.includes(searchvalue, start)7
string.includes(searchvalue, start)4string.includes(searchvalue, start)9
Dưới đây là ví dụ về chuỗi bao gồm () phương thức. & Nbsp; & nbsp;
JavaScript
Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true0Input: Welcome to GeeksforGeeks. Output: false1string.includes(searchvalue, start)6Input: Welcome to GeeksforGeeks. Output: false3
string.includes(searchvalue, start)4Input: Welcome to GeeksforGeeks. Output: false5
string.includes(searchvalue, start)2Input: Welcome to GeeksforGeeks. Output: false7
Input: Welcome to GeeksforGeeks. Output: false8
Output:
Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true2Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true3Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true4
Bàn luận
string.includes(searchvalue, start)0
string.includes(searchvalue, start)1
string.includes(searchvalue, start)2string.includes(searchvalue, start)3
string.includes(searchvalue, start)4string.includes(searchvalue, start)5string.includes(searchvalue, start)6string.includes(searchvalue, start)7
string.includes(searchvalue, start)4string.includes(searchvalue, start)9
Dưới đây là ví dụ về chuỗi bao gồm () phương thức. & Nbsp; & nbsp;
JavaScript
Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true0Input: Welcome to GeeksforGeeks. Output: false1string.includes(searchvalue, start)6Input: Welcome to GeeksforGeeks. Output: false3
string.includes(searchvalue, start)4Input: Welcome to GeeksforGeeks. Output: false5
string.includes(searchvalue, start)2Input: Welcome to GeeksforGeeks. Output: false7
Input: Welcome to GeeksforGeeks. Output: false8
Output:
Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true2Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true3Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true4
Bàn luận
string.includes(searchvalue, start)0
string.includes(searchvalue, start)1
string.includes(searchvalue, start)2string.includes(searchvalue, start)3
string.includes(searchvalue, start)4string.includes(searchvalue, start)5string.includes(searchvalue, start)6string.includes(searchvalue, start)7
string.includes(searchvalue, start)4string.includes(searchvalue, start)9
Dưới đây là ví dụ về chuỗi bao gồm () phương thức. & Nbsp; & nbsp;
JavaScript
Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true0Input: Welcome to GeeksforGeeks. Output: false1string.includes(searchvalue, start)6Input: Welcome to GeeksforGeeks. Output: false3
string.includes(searchvalue, start)4Input: Welcome to GeeksforGeeks. Output: false5
string.includes(searchvalue, start)2Input: Welcome to GeeksforGeeks. Output: false7
Input: Welcome to GeeksforGeeks. Output: false8
Output:
Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true2Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true3Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true4
Bàn luận
string.includes(searchvalue, start)0
string.includes(searchvalue, start)1
string.includes(searchvalue, start)2string.includes(searchvalue, start)3
string.includes(searchvalue, start)4string.includes(searchvalue, start)5string.includes(searchvalue, start)6string.includes(searchvalue, start)7
string.includes(searchvalue, start)4string.includes(searchvalue, start)9
Dưới đây là ví dụ về chuỗi bao gồm () phương thức. & Nbsp; & nbsp;
JavaScript
Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true0Input: Welcome to GeeksforGeeks. Output: false1string.includes(searchvalue, start)6Input: Welcome to GeeksforGeeks. Output: false3
string.includes(searchvalue, start)4Input: Welcome to GeeksforGeeks. Output: false5
string.includes(searchvalue, start)2Input: Welcome to GeeksforGeeks. Output: false7
Input: Welcome to GeeksforGeeks. Output: false8
Output:
Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true2Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true3Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true4
- Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true7Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true8Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true9
Bàn luận
string.includes(searchvalue, start)0
string.includes(searchvalue, start)1
string.includes(searchvalue, start)2string.includes(searchvalue, start)3
string.includes(searchvalue, start)4string.includes(searchvalue, start)5string.includes(searchvalue, start)6string.includes(searchvalue, start)7
string.includes(searchvalue, start)4string.includes(searchvalue, start)9
Dưới đây là ví dụ về chuỗi bao gồm () phương thức. & Nbsp; & nbsp;
JavaScript
Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true0Input: Welcome to GeeksforGeeks. Output: false1string.includes(searchvalue, start)6Input: Welcome to GeeksforGeeks. Output: false3
string.includes(searchvalue, start)4Input: Welcome to GeeksforGeeks. Output: false5
string.includes(searchvalue, start)2Input: Welcome to GeeksforGeeks. Output: false7
Input: Welcome to GeeksforGeeks. Output: false8
Output:
- Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true2Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true3Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true4
Bàn luận
string.includes(searchvalue, start)0
string.includes(searchvalue, start)1
string.includes(searchvalue, start)2string.includes(searchvalue, start)3
string.includes(searchvalue, start)4string.includes(searchvalue, start)5string.includes(searchvalue, start)6string.includes(searchvalue, start)7
string.includes(searchvalue, start)4string.includes(searchvalue, start)9
Dưới đây là ví dụ về chuỗi bao gồm () phương thức. & Nbsp; & nbsp;
JavaScript
Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true0Input: Welcome to GeeksforGeeks. Output: false1string.includes(searchvalue, start)6Input: Welcome to GeeksforGeeks. Output: false3
string.includes(searchvalue, start)4Input: Welcome to GeeksforGeeks. Output: false5
string.includes(searchvalue, start)2Input: Welcome to GeeksforGeeks. Output: false7
Input: Welcome to GeeksforGeeks. Output: false8
Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true0____21 Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true2Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true3Input : Welcome to GeeksforGeeks.
str.includes("Geeks");
Output : true4
Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true0____21 Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true7Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true8Input : Welcome to GeeksforGeeks. str.includes("Geeks"); Output : true9
- Trong JavaScript, bao gồm () phương thức xác định xem một chuỗi có chứa các ký tự đã cho trong đó hay không. nhạy cảm, nó sẽ xử lý các ký tự chữ hoa và các ký tự thường khác nhau.syntax: & nbsp; & nbsp;
- Tham số được sử dụng: & nbsp; & nbsp;
- Giá trị tìm kiếm: Đó là chuỗi mà tìm kiếm sẽ diễn ra.
- Bắt đầu: Đây là vị trí từ nơi tìm kiếm sẽ được xử lý & nbsp; (mặc dù tham số này là không cần thiết nếu điều này không được đề cập & nbsp; tìm kiếm sẽ bắt đầu từ đầu chuỗi).
- Trả về một sự thật Boolean cho thấy sự hiện diện hoặc nó trả về sai cho thấy sự vắng mặt.
Giải thích: Vì tham số thứ hai không được xác định, tìm kiếm sẽ diễn ra từ chỉ mục bắt đầu. Và nó sẽ tìm kiếm các chuyên viên máy tính, vì nó có trong chuỗi, nó sẽ trả về một sự thật. & NBSP;