当前位置:网站首页>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
边栏推荐
- 队列操作---
- 【语音信号处理】3语音信号可视化——prosody
- Deep understanding of grpc part1
- Wechat applet reports an error: [rendering layer network layer error] pages/main/main Local resource pictures in wxss cannot be obtained through wxss. You can use network pictures, Base64, or < image/
- uniapp 使用 uni-upgrade-center
- C summary of knowledge points 1
- Indefinite integral
- One year anniversary of bitbear live studio, hero rally order! I invite you to take a group photo!
- Implementation of address book management system with C language
- How to understand the developed query statements
猜你喜欢
![[datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn](/img/f2/7931952b832e84d7b8f2615906f33f.png)
[datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn

【datawhale202206】pyTorch推荐系统:召回模型 DSSM&YoutubeDNN

Istio、eBPF 和 RSocket Broker:深入研究服务网格

GID:旷视提出全方位的检测模型知识蒸馏 | CVPR 2021

Onenet Internet of things platform - the console sends commands to mqtt product devices

Binary stack (I) - principle and C implementation

【20211129】Jupyter Notebook远程服务器配置

Use set_ Handler filters out specific SystemC wrapping & error messages

Botu V15 add GSD file

91. (chapitre Cesium) simulation de lancement de fusées cesium
随机推荐
Comment Nike a - t - il dominé la première place toute l'année? Voici les derniers résultats financiers.
Message queue monitoring refund task batch process
谈思生物直播—GENOVIS张洪妍抗体特异性酶切技术助力抗体药物结构表征
The Missing Semester
Onenet Internet of things platform - the console sends commands to mqtt product devices
Mysql database knowledge collation
CPU 上下文切换的机制和类型 (CPU Context Switch)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 4
Computer graduation project asp Net attendance management system vs developing SQLSERVER database web structure c programming computer web page source code project
[datawhale202206] pytorch recommendation system: precision model deepfm & DIN
Building external modules
Onenet Internet of things platform - create mqtts products and devices
How does Nike dominate the list all the year round? Here comes the answer to the latest financial report
指纹浏览器工作原理、使用场景以及重要性简单讲解
Emotion analysis based on IMDB comment data set
Why does the JVM heap memory exceed 32g and pointer compression fail?
我在中山,到哪里开户比较好?实际上网上开户安全么?
Unity XLua 协程封装
【单片机】【数码管】数码管显示
241. 为运算表达式设计优先级 : DFS 运用题