当前位置:网站首页>JS related interview questions and answers (1)
JS related interview questions and answers (1)
2022-07-01 12:13:00 【Kekechen】
js What are the basic data types ?
- Number
- String
- Boolean
- Undefined
- Null
Ajax How to use ?
establish XMLHttpRequest object
grammar :let xhr = new XMLHttpRequest();
Send request to server
get The way : call open Method , Parameter is ( Request mode , Request address + Request parameters , Asynchronous or not )
call send() Method
post The way : call open Method , Parameter is ( Request mode , Request address , Asynchronous or not )
Add request header :xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
call send( Request parameters ) Method
Receive server response
Use onreadystatechange event :
How to write it :xhr.onreadystatechange=function(){
if(xhr.readyState==4&&xhr.status==200){
fun(xhr.responseText);
}
How to judge whether a data is NaN?
NaN Is not a number and the data type is Number, And it doesn't mean itself
utilize NaN Not equal to unique, not equal to their own characteristics :
How to write it :funcion isNaN(n){
if(n!=n){
return true;
}else{
return false
}}
Null And Undefined difference
The same thing : stay if In the judgment statement , Will be converted to false
Difference : Convert to Number type ,null by 0,undefined by NaN
null Indicates that a value defines , But it is assigned a null value ;undefined The expression defines , No assignment
Characteristics of closure function ?
A closure can be understood as a function defined within a function , When one of the internal functions is called outside the external function containing them , It's a closure .
How to write it :
let fun = (function(){
var count=0;
return function(){
return ++count;
}})()
The nature of closures :
The outer function is nested with an inner function , Operate on local variables in sub functions , Take the child function as the return value of the parent function , Bind the return value of the parent function through a global variable , Thus, the life cycle of sub functions and local variables is prolonged , It realizes that the local variables inside the function can be operated outside the function
characteristic :
- Function nested function
- Functions can reference external parameters and variables internally
- Parameters and variables are not recycled by the garbage collection mechanism
use :
- Read the variables inside the function ;
- The values of these variables are always kept in memory , It will not be automatically cleared after the outer function call
shortcoming :
- Can cause memory leaks
边栏推荐
- Computer graduation project asp Net hotel room management system VS development SQLSERVER database web structure c programming computer web page source code project
- usb peripheral 驱动 - cable connect/disconnect
- Building external modules
- The Missing Semester
- uniapp 使用 uni-upgrade-center
- S7-1500plc simulation
- Computer graduation project asp Net attendance management system vs developing SQLSERVER database web structure c programming computer web page source code project
- Golang des-cbc
- 【20220605】文献翻译——虚拟现实中的可视化:一个系统的回顾
- Use of easyexcel
猜你喜欢
随机推荐
One year anniversary of bitbear live studio, hero rally order! I invite you to take a group photo!
usb peripheral 驱动 - cable connect/disconnect
[datawhale202206] pytorch recommendation system: multi task learning esmm & MMOE
Technology sharing | MySQL: how about copying half a transaction from the database?
I'm in Zhongshan. Where is a better place to open an account? Is it actually safe to open an account online?
91. (cesium chapter) cesium rocket launch simulation
C summary of knowledge points 1
C#依赖注入(直白明了)讲解 一看就会系列
[Yu Yue education] financial management reference materials of Ningbo University of Finance and Economics
谈思生物直播—GENOVIS张洪妍抗体特异性酶切技术助力抗体药物结构表征
栈-------
Virtualenv+pipenv virtual environment management
Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
Abbirb120 industrial robot mechanical zero position
The specified service is marked for deletion
[speech signal processing] 3 speech signal visualization -- prosody
陈珙:微服务,它还那么纯粹吗?
Unity XLua 协程封装
Understanding of MVVM and MVC
队列操作---








