办 个 假 的 毕 业 证 多 少

打不开█,█请薇█信   电话:15675872669██,

JS的数据类型
typeof能检测出来的:                                基本类型6种还有自定义类型
number,string,boolean,object,undefined,function
资料显示:
+ null



instanceof与typeof的区别
typeof:当前对象的数据类型是什么
instanceof:当前对象是否为类的实例
var dog=new Animal('旺财',20);
typeof dog;//object
dog instanceof Animal;//true       
dog instanceof Array;//false
dog instanceof Object;//true
call与apply的区别
function show(a,b){
console.log(this);
return a+b;
}
普通: show(1,2);//this是window
apply: show.apply(dog,[1,2]);//this是dog
call: show.call(dog,1,2);//this是dog
场景:
Math.max.apply(null,arr);//求数组中的最大值
 
 
 事件源
 事件捕获和事件冒泡

事件冒泡[false]:当你使用事件冒泡时,子级元素先触发,父级元素后触发。

事件捕获[true]:当你使用事件捕获时,父级元素先触发,子级元素后触发。

function showType(event){  ☆

event.type;//事件类型

event.target;//触发事件的元素

event.currentTarget;//绑定事件监听的那个对象,也就是委托的父元素  给谁绑定的事件

event.stopPropagation();//阻止事件冒泡,上级元素无法得到事件  阻止事件冒泡(父元素无法获得事件)

event.cancelable;//当前元素是否具有默认行为   判断当前行为是否具有默认行为

event.preventDefault();//阻止当前元素的默认行为  阻止默认行为

}

(不带小括号的函数调用,存在事件对象event)

(带小括号的函数调用,传参数:event)

(事件触发规则需要在父级元素指定)

 
 
 事件委托(代理)
 
 事件委托兼容写法 ☆
 

补充:

word-break:break all;  字母数字全都换行

pattern="^$"  可以直接在input写正则表达式

autocomplete=“on/off” 自动完成功能

一道练习题

<!-- 题目一给定var str ="ryan is not a good man";
把这个字符串变成"ryan5 is6 not7 a8 good9 man10" -->
 
var str ="ryan is not a good man";
var str2=str.split(" ");
var b=5;
for(var i=0;i<str2.length;i++){
str2[i]=str2[i]+b;
b++;
}
var str3=str2.join(' ');
console.log(str3);

猜你喜欢

转载自www.cnblogs.com/taiyuandaiyun/p/9803584.html