undefined
0.9
0.8
0.7000000000000001
0.6
0.5
0.4
0.30000000000000004
0.19999999999999998
0.1
0
конец
if(el.style.opacity == "") {
el.style.opacity = 1;
opacity = el.style.opacity;
}
else if(typeof opacity !== 'undefined') {
el.style.opacity = opacity;
}
else {
opacity = el.style.opacity;
}
My point is that use single state tree unless it is awkward, and only do this when it simplifies things for you rather than complicates them. That’s the only guideline.
(async() => {
setTimeout(() => console.log('1000'), 1000);
await sleep(5000);
console.log('5');
await sleep(5000);
console.log('5');
})();
(() => {
setTimeout(() => console.log('1000'), 1000);
sleep(5000).then(() => {
console.log('5');
sleep(5000).then(() => {
console.log('5');
};
});
})();
function resolveAfter2Seconds(x) {
return new Promise(resolve => {
setTimeout(() => {
resolve(x);
}, 2000);
});
}
async function add1(x) {
var a = resolveAfter2Seconds(20);
var b = resolveAfter2Seconds(30);
return x + await a + await b;
}
function resolveAfter2Seconds(x) {
return new Promise(resolve => {
setTimeout(() => {
resolve(x);
}, 2000);
});
}
function add1(x) {
var a = resolveAfter2Seconds(20);
var b = resolveAfter2Seconds(30);
return new Promise(resolve => {
Promise.all([a, b]).then(results => {
resolve(x + results[0] + results[1]);
})
});
}
class Example extends Component {
state = {
form: {
inputValue: '',
textareaValue: '',
},
};
handleChange = e => {
const { name, value } = e.target;
this.setState(prevState => ({
form: {
...prevState.form,
[name]: value,
},
}));
};
render() {
const { inputValue, textareaValue } = this.state;
return (
<Wrapper>
<input
name="inputValue"
value={inputValue}
onChange={this.handleChange}
/>
<textarea
name="textareaValue"
value={textareaValue}
onChange={this.handleChange}
/>
...
</Wrapper>
);
}
function addEventListener(string,func){
if (клик произошел){
func.call(this, event);
}
}