1.html或者jsp中嵌入js的方式:
1.1外部应用:
js文件只要书写 js代码即可 不需要使用包裹(最好写在HTML 的后面)
1.3行内样式
在html元素标签中写入例:;
2查看变量类型和js中的变量
2.1查看变量类型使用:typeof
例:alert(typeof a);
数据 | 返回值 |
---|---|
声明未赋值 | undefind |
boolean | true/false |
number | 整数或浮点数 |
object | 对象数组 |
string | 单引号或双引号 |
3.string对象的操作
字符串.方法
方法 | 返回类型 |
---|---|
charAt(index) | 返回下标是index的字符 |
indexof(str,index) | 返回str字符串在整个字符串中首次出现的位置 |
substring(index1,index2) | 返回下标在index1与index2之间的字符串(左闭右开) |
splite(“,”) | 将字符串以逗号进行分割返回分割后的字符数组 |
4.创建数组
4.1创建数组的方式:
4.1.1
var 数组名=new array(长度);
数组名[i]=…
4.1.2
var 数组名=new array (“”,“”,‘’,);
4.1.3
var 数组名=[“一”,“而”,“三”];
5.数组的相关方法和属性
https://blog.youkuaiyun.com/Freya_yyy/article/details/84780003?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522160310220319195188319173%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=160310220319195188319173&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_v2~rank_v28-1-84780003.first_rank_ecpm_v3_pc_rank_v2&utm_term=js%E4%B8%AD%E6%95%B0%E7%BB%84%E7%9A%84%E5%B1%9E%E6%80%A7%E4%B8%8E%E6%96%B9%E6%B3%95&spm=1018.2118.3001.4187