using async/await to catch errors
javascript,es6,object,web_development
async function executeAsyncTask () {
try {
const valueA = await functionA();
const valueB = await functionB(valueA);
const valueC = await functionC(valueB);
return await functionD(valueC);
}
catch (err) {
logger.error(err);
} finally {
await alwaysExecuteThisFunction();
}
}Có thể bạn đã miss một số snippets code
Filter Unique Values
Kiểu đối tượng Set đã được giới thiệu trong ES6 và cùng với ..., ‘spread’ operator, chúng ta có thể sử dụng nó để tạo một mảng mới chỉ với các giá trị duy nhất.
serialize Form
Sử dụng formdata constructor để convert form, FormData, array.from(). Kết hợp window.encodeURIComponent() để encode từng value trong form.
Calculate the number of difference days between two dates
Calculate the number of difference days between two dates
Get value select option JavaScript
How do I get the text value of a selected option and get value select option by Jquery.
Clone Objects in JavaScript
3 Ways to Clone Objects in JavaScript