常用API

一.字符串对象

.length 获取数组长度

[] 下标  从0开始,不管是文字还是标点符号在字符串里面都占一个位置

//如果在引号里面加引号,外单内双,内双外单

indexOf  数组去重: 1.查找字符串

                              2.如果当前字符串中存在该字符那么返回该字符的下标

                              3.如果当前字符串中不存在的该字符那么返回的是-1

                             4.如果不止一个字符也就是在多个情况下,返回的是从左往右数最近的那一个字符的小标

lastindexOf: 1.查找字符串  2.不存在的该字符那么返回的是-1,如果存在它查找的是从右往左进行查找

注意:下标的顺序永远不会发生改变

match:查找字符串 1.如果该字符存在会返回一个数组,里面包含找到的该字符,该字符的下标,整个字符串都会被返回
replace: 替换内容  (第一个是要被替换字符,要替换成什么字符)

toUpperCase()   英文转大写

toLowerCase 英文转小写

// toString 将number类型转换为string类型2.转换进制

var num = 123.389;
             console.log( typeof num.toString());
             console.log( num.toString(2));

  // Number () 将任意类型转换为number类型

        var bool = true;
             console.log(Number(bool));

 // split 1.将字符串转为数组2.分割字符串然后回复相应的数组内容(看自己当前数据具备用什么符号进行分割)

 console.log(str.split(","));
二.Math

// Math  Math.ceil() 永远前一位进 1.向上舍入

// Math.floor() 向下舍入 2.搭配随机数使用

 // Math.round() 四舍五入

三.Date

var time = new Date();

年:            console.log(time.getFullYear());

月:             console.log(time.getMonth());

 日:            console.log(time.getDate());

 时:            console.log(time.getHours());

 分:           console.log(time.getMinutes());

 秒:         console.log(time.getSeconds());

正则表达式: test

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值