当前位置:网站首页>JS common interview questions
JS common interview questions
2022-07-25 03:07:00 【Gary_ Leong】
map and forEach The difference between
- map It's faster than forEach;
- map Will return a new array , It doesn't change the original array ;forEach No new array will be returned , It is allowed to modify the original array ;
- They all have parameters :item、index、arr
- Of internal anonymous functions this All points are window;
String to character array
- split() Method
const text = "abc";
const chars = text.split('');
console.log(chars);
//['a', 'b', 'c']
- Expand operator
Expand operator ( …) Allow multiple elements when needed ( Such as array text ) Where to extend iteratable objects such as strings .
This is an example of expanding a string into a character array . Correctly handle characters with two code units .
const text = "abc????";
const chars = [ ...text ];
console.log(chars);
//["a", "b", "c", "????"]
- Deconstruct assignment
Deconstruction assignment syntax can unpack the values in an array or an iteratable object into different variables .
When deconstructing arrays or iteratable objects , We can use rest The pattern extracts the rest of it into a single variable .
const text = "abc????";
const [ ...chars ] = text;
console.log(chars);
//["a", "b", "c", "????"]
- Array.from
Array.from Assists in creating new arrays of objects that are arrayed or iterated . Strings are both iteratable and similar to arrays , therefore , It can be successfully converted to a character array .
const text = "abc????";
const chars = Array.from(text);
console.log(chars);
//["a", "b", "c", "????"]
边栏推荐
- List title of force buckle summary
- Publish the project online and don't want to open a port
- Read and upgrade st-link chip information and SWD burning media through STM32 stlink utility tool
- JS foundation -- data
- Wechat H5 record
- Color space (1) - RGB
- List.stream common operations
- Execution methods with static code blocks and child and parent classes
- Domain driven model (DDD)
- Go common standard library -time
猜你喜欢

JS foundation -- hijacking of this keyword

Conceptual distinction between Po, Bo, VO, dto and POJO
![[stm32f103rct6] can communication](/img/24/71509bd0d74d43ce4a79b8126478ff.jpg)
[stm32f103rct6] can communication

Pagoda workman WSS reverse proxy socket legal domain name applet chat remove port

Arduino IDE for raspberry PI Pico development firmware localization installation tutorial

How to take the mold for the picture of 1.54 inch TFT st7789 LCD screen

Stm32cubemx quadrature encoder

JS foundation -- data

Tp5.1 include include files (reference public files)

Request and response
随机推荐
Hyperchain hyperblockchain Shi Xingguo was interviewed by 36 krypton: the amount of customer cooperation consulting is doubling
JS written test questions -- random numbers, array de duplication
Banana pie bpi-m5 toss record (3) -- compile BSP
MySQL configuration in CDH installation
# CF #808 Div.2(A - C)
Enter an integer and a binary tree
Arduino IDE for raspberry PI Pico development firmware localization installation tutorial
ECMAScript new features
Inheritance (prototype)
Nuscenes data set summary
[stm32f103rct6] can communication
JS foundation -- hijacking of this keyword
Unified return data format
Use pytest + allure to show the chart results (3)
Riotboard development board series notes (4) -- using Vpu hardware decoding
Preliminary foundation JVM
Node queries the path of all files (files or folders) named filename under the target directory
Wechat sports field reservation of applet completion works applet graduation design (8) graduation design thesis template
Learning record 10
What should I do when the interface encounters jsonstring