requirement is how to determine that the key already exists and then deal with it differently when adding a key value to the map?
let msg = new Map()
msg.set("a",{count: 10})
msg.set("a",{count: 20})
a count,a,
how should this be achieved?
requirement is how to determine that the key already exists and then deal with it differently when adding a key value to the map?
let msg = new Map()
msg.set("a",{count: 10})
msg.set("a",{count: 20})
a count,a,
how should this be achieved?
opening the console and swinging the keyboard is a new Map ()
MDN:
?:
let msg = new Map()
msg.set('a',{count: 10})
if(msg.has('a')){
let data=msg.get('a')
data.count+=10
msg.set('a',data)
}else{
msg.set('a',{count:10})
}
borrow the method upstairs,
let msg = new Map()
msg.set('a',{count: 10});
if(msg.has('a')) {
var val = msg.get('a').count;
val += val;
msg.set('a',{count: val} )
}else {
mgs.set('a', {count: 10})
}
I need to implement in a chained promise function, any function error in the middle terminates the program, and can catch the error function, and then perform different operations according to different error functions. How can the following code be imp...
import React from react ; class PublicScreen extends React.Component { constructor(props) { super(props); this.getStyle = this.getStyle.bind(this); } getStyle() { const { width = 1920, height = 1080 } = this.pr...
read a number, such as 521 change this number to 0521 but put it into four div separately, how to realize it? 0 < div > 5 < div > 2 < div > 1 < div > ...
originally run directly in the browser (Chrome 65) will report ReferenceError errors, but after babel conversion, and then run, it will be undefined, these two errors are completely different, does it mean that the conversion of babel is not complete? ...
import React from react ; import ReactDOM from react-dom ; import . assets styles index.less ; import Green from . assets images green.png ; import Red from . assets images red.png ; class Circle extends React.Component { constructor...
function foo(){ setTimeout(()=>{ console.log("is:",this.id); 42 },100) } var id = 21; foo.call({id:42}) The this of the function in js is dynamic, depending on who calls it at run time, in which the this inside foo points to an a...
how do I use generator to achieve the following functions? function f1(){ return new Promise((resolve,reject) =>{ setTimeout(() =>{ resolve(1); },1000) }) } function f2(valu...
test(...arg) { console.log("",arg); } render(){ return <View style={{flex:1,backgroundColor:"blue"}}> <TouchableOpacity activeOpacity={1} onPress={this. test("")}&...
insert a large number of pictures into the project, how to simplify import React from react ; import ReactDOM from react-dom ; import . assets styles index.less ; import A0 from . assets images A0.png ; import A1 from . assets images A1.p...
under normal circumstances, variables declared by let or const cannot be declared repeatedly, and an error will be reported even when using var. eg: let a = 123; var a = 456; error prompt: Uncaught SyntaxError: Identifier a has already been declar...
I don t understand why this is window in this broken code. Thank you for your understanding. Thank you. var o = { fn:() => { console.log(this) } } o.fn() ...
I want to return a data corresponding to id based on the data.id passed in ...
< H1 > Ruan Yifeng: the extension operator (spread) is three dots (.). It is like the inverse operation of rest parameters, converting an array into a sequence of parameters separated by commas. < H1 > what does the inverse operation of rest parameter...
in es6. The extension operator expands the array [1Magol 2pr 3] unfolds as 1Magol 2Jol 3, so what is this 1Magol 2Jol 3? An array is not an array, a string is not a string later, there was also the operation of the object. The operator is called de...
<div className={ break_down_div }> {this.state.breakDown && this.state.breakDown.length != 0? <canvas className={ blueCircle } >< canvas> <div re...
1. How to implement a general regular validation form with the least amount of code = project, 1. Login has two input (verify mailbox, password 10 digits + letters) 2. input () both forms are displayed after input loses focus (correct or w...
first of all, there is such a piece of data list[ zhangsan , lisi , wangmazi ] people[ { name: zhangsan , username: },{ name: lisi , username: },{ name: wangmazi , username: } ] then the qu...
looking at the Vue official website tutorial, there are the following suggestions for adding multiple attributes: = split line = if you want to add new responsive attributes, don t be like this: Object.assign ( vm.userProfile , { age: 27, favorit...
I have a vue project where ajax requests are sent using axios. one of the list pages, clicking on the list will send the details of the corresponding list of the request query. now in order to prevent frequent requests from being sent due to multiple ...
< H2 > original question: < H2 > A module that uses ES6 in a smart editor (such as WebStorm) introduces a module, first import {} from fs ; and then jump the cursor back to curly braces {} to write the desired module, because there is a smart ...