javascript 函数表达
1.if格式
if (){}
或者 if(){
}else if(){}
else{
}
2.for 循环

3.do while 循环

4.while循环

5.switch
语句格式
switch()
case '':
break;
case '' :
break
default;
*5.string字符匹配等

x(未知数).charAT(i)获取当前小标为i的字符
1.匹配字符
(1.)indexof(str(str指的是当前要被匹配的字符串));从当前文本中查找是否存在str字符串,返回首字符起始的下标值,如果当前文本中没有此字符串,返回-1
(2.)indexof(str(str指的是当前要被匹配的字符串),下标值);从当前文本中以下标值多少开始查找是否存在str字符串,返回首字符起始的下标值,如果当前文本中没有此字符串,返回-1
(3.) lastindexof(str);从后面开始找,返回从前面开始的下标值。
(4.)lastindexof(str,startindex)从后面开始找,startindex是从前面的下标开始数,如果是10,即下标为10后面的不要,下标为10开始往前面找
2.裁剪字符
(1.)substr(下标位) 从当前给出的下标位开始裁剪,留下后面的字符串。
(1.)substr(下标位,长度)
从当前给出的下标位开始以长度为多少来结束。
3.isNaN
true 不是一个数字
flase 是一个数字
4.typeof 判断类型
for if else 实战练习
1 如何用js写一个回文程序
回文的格式:1234321
2.如何写一个分别统计输入数字和字母的js程序
3.如何写一个猜数字的js程序
4.如何写一个菲波函数的程序
菲波函数格式:1,1,2,3,5,8,13,21;
f3=f1+f2
网友评论