学习笔记整理第二天

本文介绍了JavaScript中使用split()方法处理字符串,将其转换为数组的技巧,包括按空格和字符分割,以及如何利用toLowerCase()和toUpperCase()进行大小写转换。同时,探讨了element.classList的add()和remove()方法在DOM操作中的应用。

May 14

split() 方法使用指定的分隔符字符串将一个String对象分割成字符串数组,以将字符串分隔为子字符串,以确定每个拆分的位置。

var str = 'The quick brown fox jumps over the lazy dog.';

var words = str.split(' ');
console.log(words[3]);
// expected output: "fox"

var chars = str.split('');
console.log(chars[8]);
// expected output: "k"

var strCopy = str.split();
console.log(strCopy);
// expected output: Array ["The quick brown fox jumps over the lazy dog."]

toLowerCase()方法返回转换为小写的调用字符串值

toUpperCase 则相反

 

element.classList 本身是只读的,但是你可以使用 add()  remove()方法修改它。

add( String [, String] )添加指定的类值。如果这些类已经存在于元素的属性中,那么它们将被忽略。

remove( String [,String] )删除指定的类值。

 

!优先级别比较低需要在后面加上括号   if(!(a === 1))

转载于:https://www.cnblogs.com/-constructor/p/10862048.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值