20 lines
428 B
TypeScript
20 lines
428 B
TypeScript
|
|
// 判断是否为字符串
|
|
typeof '' === 'string';
|
|
|
|
// 判断字符串是否包含子串,区分大小写
|
|
'Blue Whale'.includes('blue'); // returns false
|
|
'blue ss'.indexOf('blue');
|
|
|
|
// str.substring(indexStart[, indexEnd])
|
|
|
|
|
|
// 向下取整 floor
|
|
Math.floor( 45.95); // 45
|
|
// 向上取整 ceil
|
|
Math.ceil(.95) // 1
|
|
|
|
// 给定数字的值四舍五入到最接近的整数。
|
|
Math.round(20.49); //20
|
|
Math.round(20.5); //21
|