1.说一下<label>标签的用法

label标签主要是方便鼠标点击使用,扩大可点击的范围,增强用户操作体验

2.说一下事件代理?

事件委托是指将事件绑定到目标元素的父元素上,利用冒泡机制触发该事件

ulEl.addEventListener('click', function(e){
var target = event.target || event.srcElement;
if(!!target && target.nodeName.toUpperCase() === "LI"){
console.log(target.innerHTML);
}
}, false);

3.说一下宏任务和微任务?

JS是单进程模式,他会先执行同步,再执行微队列,后在执行宏队列。
微队列:promise回调、mutation回调
宏队列:DOM事件回调、ajax回调、定时器回调

4.说一下继承的几种方式及优缺点?

  • 原型链继承
function Parent(){
this.name=["KE","gg"]
}
Parent.prototype.getName=(){
console.log(this.name)}
function.Child(){
 
}
Child.prototype=new Parent()
var child1=new Child()
child1.name.push("tt")//["KE","gg","tt"]
var child2=new Child()
child2.name.push("hh")//["KE","gg","tt","hh"]
优点:简单、父类和子类共享属性
缺点:1.引用类型属性共享,2.创建Child实例时,不能像Parent传入参数
  • 构造函数继承
function Parent(){
this.name=["KE","gg"]
}
Parent.prototype.getName=(){
console.log(this.name)}
function.Child(){
Parent.call(this)
}
 
var child1=new Child()
child1.name.push("tt")//["KE","gg",'tt']
var child2=new Child()
child2.name.push("hh")//["KE","gg",'hh']
比较原型链继承
优点:1.不会实例共享引用型属性,2.可以向父传参
缺点:每创建一次实例就会重新生成方法属性
原型链的优缺点和构造函数优缺点相反
  • 组合继承
function Parent(color){
this.name=["KE","gg"],
this.color=color
}
Parent.prototype.getName=(){
console.log(this.name)}
function.Child(color,age){
Parent.call(this,color)
this.age=age
}
Child.prototype=new Parent()
var child1=new Child("red")
child1.name.push("tt")//["KE","gg",'tt']
child1.color//red
var child1=new Child("green")
child1.name.push("hh")//["KE","gg",'hh']
child1.color//green
优点:融合了原型链和构造函数继承的优点
  • 原型式继承
function createObj(o){
function f(){}
f.prototype=os
return new f()
}
缺点:实例共享引用型的属性
  • 寄生式继承
function createObj(o){
var clone=Object.create(o)
clone.sayName=function(){
console.log(0)
}
return clone
}
缺点:创建一次实例创建一次方法
  • 寄生式组合继承
function object(o){
function f(){}
f.prototype=o
return new f()
}
function protot(child,parent){
var prototype=object(parent.prototype)
prototype.constructor=child
child.prototype=prototype
}
调用两次构造函数

5.说一下自己常用的es6的功能?

1.let、const
2.解构
3.模板字符串
4.es6模块导出
5.类写法
6.promise对象
7.箭头函数
参考文献:
https://www.cnblogs.com/XYQ-208910/p/11942974.html

6.什么是会话cookie,什么是持久cookie?

cookie是服务器返回的,指定了expire time(有效期)的是持久cookie,没有指定的是会话cookie

7.数组去重?

js

var arr=['12','32','89','12','12','78','12','32'];
// 最简单数组去重法
function unique1(array){
var n = []; //一个新的临时数组
for(var i = 0; i < array.length; i++){ //遍历当前数组
if (n.indexOf(array[i]) == -1)
n.push(array[i]);
}
return n;
}
arr=unique1(arr);
// 速度最快, 占空间最多(空间换时间)
function unique2(array){
var n = {}, r = [], type;
for (var i = 0; i < array.length; i++) {
type = typeof array[i];
if (!n[array[i]]) {
n[array[i]] = [type];
r.push(array[i]);
} else if (n[array[i]].indexOf(type) < 0) {
n[array[i]].push(type);
r.push(array[i]);
}
}
return r;
}
//数组下标判断法
function unique3(array){
var n = [array[0]]; //结果数组
for(var i = 1; i < array.length; i++) { //从第二项开始遍历
if (array.indexOf(array[i]) == i)
n.push(array[i]);
}
return n;
}

es6

es6方法数组去重
arr=[...new Set(arr)];
es6方法数组去重,第二种方法
function dedupe(array) {
return Array.from(new Set(array)); //Array.from()能把set结构转换为数组
}

8.get、post的区别

1.get传参方式是通过地址栏URL传递,是可以直接看到get传递的参数,post传参方式参数URL不可见,get把请求的数据在URL后通过?连接,通过&进行参数分割。psot将参数存放在HTTP的包体内

2.get传递数据是通过URL进行传递,对传递的数据长度是受到URL大小的限制,URL最大长度是2048个字符。post没有长度限制

3.get后退不会有影响,post后退会重新进行提交

4.get请求可以被缓存,post不可以被缓存

5.get请求只URL编码,post支持多种编码方式

6.get请求的记录会留在历史记录中,post请求不会留在历史记录

7.get只支持ASCII字符,post没有字符类型限制

 

随机推荐

  1. 开发你的第一个NCS(Zephyr)应用程序

    Nordic有2套并存的SDK:老的nRF5 SDK和新的NCS SDK,两套SDK相互独立,大家选择其中一套进行开发即可.一般而言,如果你选择的芯片是nRF51或者nRF52系列,那么推荐使用nRF ...

  2. Mysql5.7.20安装手记

    Mysql到5.7之后安装较之前有了很大的不同,特别是解压缩版,可能安装速度较之前有所减少,但对于我们这种一直使用5.5的我来说不知道步骤还真是挺费劲的.下面详细记一下我安装的过程. 1.下载mysq ...

  3. (十)、cat--查看文件命令

    一.命令描述与格式 将文件或标准输入组合输出到标准输出,所以注定了其可以配合管道应用, 格式:cat    [选项]    [files] 选项: -A   --show-all            ...

  4. Error:(12, 24) 警告: [deprecation] android.hardware中的Camera已过时.android

    问题:android studio编译项目时出现: Error:(12, 24) 警告: [deprecation] android.hardware中的Camera已过时 解决:(只是让其不提示) ...

  5. JavaWeb基础总结:Filter专题

    Java Servlet Filter Filter 被称为过滤器,其主要作用是对 Servlet 容器调用 Servlet 的过程进行拦截,从而在 Servlet 进行响应处理的前后实现一些特殊功能 ...

  6. 还在使用Future轮询获取结果吗?CompletionService快来了解下吧。

    背景 二胖上次写完参数校验(<二胖写参数校验的坎坷之路>)之后,领导一直不给他安排其他开发任务,就一直让他看看代码熟悉业务.二胖每天上班除了偶尔跟坐在隔壁的前端小姐姐聊聊天,就是看看这些 ...

  7. 记 CentOS 服务器上安装 neo4j 图数据库及本地访问

    下载 去官网下载压缩包放到服务器上.地址为neo4j 下载中心,我这里选择的是 Neo4j 3.5.25 (tar).具体如何做呢?我这里使用的是土方法,即先压缩包下载到本地电脑(win 10系统), ...

  8. Spring Cloud Eureka 简单创建

    1.pom.xml 添加相关依赖 <dependency>     <groupId>org.springframework.cloud</groupId>    ...

  9. SpringBoot异常处理(二)

    参数校验机制 JSR-303 Hibernate 参数接收方式: URL路径中的参数 {id} (@PathVariable(name="id") int-whatever) UR ...

  10. python实例:解决经典扑克牌游戏 -- 四张牌凑24点 (二)

    Hey! 如果你还没有看这篇的上文的话,可以去稍稍瞅一眼,会帮助加速理解这一篇里面涉及到的递归结构哦!(上一篇点这里:<python实例:解决经典扑克牌游戏 -- 四张牌凑24点 (一)> ...