当前位置:网站首页>ECMAScript6面试题
ECMAScript6面试题
2022-06-12 07:35:00 【是张鱼小丸子鸭】
1.请描述let与const以及var的区别?以及什么是暂时性死区?什么是变量提升?
区别:
暂时性死区:
变量提升:
2.请说一下你对es6的模版字符串的理解?有什么特点?
3.请说一下箭头函数与普通函数的区别?
4.请说一下什么是函数的默认参数?
5,请说一下Object.assign()的有什么作用 ?
6.请说一下你对promise的理解?并说一下promise你是如何使用的?
7.请说一下你对es6模块化的理解?
8.请说一下 es5与es6的区别?
9.请说一下使用箭头函数应该要注意什么?
1.箭头函数没有自己的this对象
(1)普通的函数,this指向的是事件源本身,如果内部有嵌套,this的指向就会发生转移
(2)箭头函数,this指向的是调用该函数的对象(this的指向是静态的)
2、箭头函数不可以当作构造函数,即不可以对箭头函数使用new命令,否则会抛出一个错误
3、不可以使用arguments对象,该对象在函数体内不存在,如果要用,可以用reset参数代替
4、不可使用yield命令,因此箭头函数不能用作Generator函数
10.请说一下es6有哪些新增的特性?
11.请说一下你对es6 class类的理解?
12.请说一下什么是深拷贝,什么是浅拷贝?以及如何实现深拷贝与浅拷贝?用 es6如何实现深拷贝?
在了解浅拷贝和深拷贝之前,我们先了解一下js的数据类型
js的数据类型分为两种
一种是基本数据类型:字符串(String)、数字(Number)、布尔(Boolean)、对空(Null)、未定义(Undefined)
一种是引用数据类型:对象(Object)、数组(Array)、函数(Function)
基本类型的变量是存放在栈内存,引用数据类型是放在堆内存中的,基本数据类型保存的是值,而引用数据类型一般保存的是对象的地址。
如果我们单纯的复制的话,可能就只是复制对象的地址,那么这就是浅拷贝,如果是克隆了对象,改变了引用对象的地址,那么就是深拷贝
浅拷贝就是拷贝指向对象的指针
深拷贝就是克隆了对象,并重新在堆中指向了一个新的地址
只有引用数据类型才存在浅拷贝和深拷贝,基本数据类型就是赋值
浅拷贝和深拷贝的区别是:看复制的子对象是否在堆内存中指向一个新的地址
实现一个深拷贝实现思路:
- 检查类型,判断类型是否为引用类型,是就进行深拷贝,否则浅拷贝
- 使用递归
- 检查环,判断当前引用是否指向自身,避免进入死循环
- 需要忽略原型
快捷深拷贝的方法
通过序列化和反序列化得到一个新的对象,JSON.parse(JSON.stringify(a));缺点:会忽略 Function、Symbol、undefined,造成属性丢失,如果在知道深拷贝对象的类型中不含有这些类型的话,这个方法还是相当的好用。
第三方工具:jquery 提供一个$.extend可以用来做深拷贝,lodash函数库提供的_.cloneDeep也可以用来做深拷贝
13.举一些ES6对String字符串类型做的常用升级优化?
14.举一些ES6对Array数组类型做的常用升级优化?
15.Map是什么,有什么作用?
16.Set是什么,有什么作用?
17.Proxy是什么,有什么作用?
18.Class、extends是什么,有什么作用?
19.常前端代码开发中,有哪些值得用ES6去改进的编程优化或者规范?
20.什么是 Babel?
边栏推荐
- Demonstrate "topic communication, action communication, service communication and parameter server" with a small turtle case
- Voice assistant - those classification models used in the assistant
- MySQL索引(一篇文章轻松搞定)
- R语言使用caTools包的sample.split函数将机器学习数据集划分为训练集和测试集
- Construction of running water lamp experiment with simulation software proteus
- 2022年危险化学品经营单位安全管理人员特种作业证考试题库及答案
- What is a good recommendation system?
- QT realization tray
- R语言将dataframe数据中指定数据列的数据从小数转化为百分比表示、数据转换为百分数
- Voice assistant - overall architecture and design
猜你喜欢

Day 4 of pyhon

Gradient epic memory for continuous learning

面试计算机网络-传输层

modelarts二
![[tutorial] deployment process of yolov5 based on tensorflow Lite](/img/d0/c38f27ad76b62b27cdeb68728e9c8c.jpg)
[tutorial] deployment process of yolov5 based on tensorflow Lite

Exploring shared representations for personalized federated learning paper notes + code interpretation

Detailed explanation of multi coordinate transformation in ROS (example + code)

Voice assistant - Qu - ner and intention slot model

What is a good recommendation system?

Voice assistant - those classification models used in the assistant
随机推荐
C language queue implementation
C language sizeof strlen
AI狂想|来这场大会,一起盘盘 AI 的新工具!
Hongmeng OS first training
Modelarts training task 1
Voice assistant - overall architecture and design
Shortcut key modification of TMUX and VIM
There is no solid line connection between many devices in Proteus circuit simulation design diagram. How are they realized?
Complete set of typescript Basics
Personalized federated learning using hypernetworks paper reading notes + code interpretation
2022年危险化学品经营单位安全管理人员特种作业证考试题库及答案
Understanding management - four dimensions of executive power
The function of C language string Terminator
2022电工(初级)考试题库及模拟考试
Thyristor, it is a very important AC control device
Modelants II
Personalized federated learning with exact stochastic gradient descent
[college entrance examination] prospective college students look at it, choose the direction and future, and grasp it by themselves
AI fanaticism | come to this conference and work together on the new tools of AI!
FCPX插件:简约线条呼出文字标题介绍动画Call Outs With Photo Placeholders for FCPX