Appearance
检验指定索引处是不是某个字符
语法
js
import { checkCharAtIndex } from 'warbler-js';
const result = checkCharAtIndex(str);
参数
str
(String) : 需要检验的字符串。char
(String) : 需要检验的字符。index
(Number) : 需要检验的索引。
返回值
Boolean : true
是 ,false
不是。
源码
js
const checkCharAtIndex = (str, char, index) => str.charAt(index) === char;
例子
js
import { checkCharAtIndex } from 'warbler-js';
const str = 'Hello, World!';
const result1 = checkCharAtIndex(str, 'H', 0);
const result2 = checkCharAtIndex(str, 'l', 2);
const result3 = checkCharAtIndex(str, 'A', 3);
console.log(result1); //= > true
console.log(result2); //= > true
console.log(result3); //= > false
添加版本
1.2.2