try/catch es10

es10,function,tipjs

An update for developer convience allows the use of try/catch without an explicit e Error reference in the catch call.

// Before
try {
  fetch('https://example.com')
} catch (e) {
  console.log(`e`)
}

After:

// After
try {
  fetch('https://example.com')
} catch {
  console.log(`something wrong.`)
}

Có thể bạn đã miss một số snippets code

Remove array of objects from another array of objects

Remove array of objects from another array of objects

String.prototype.trimStart

trimStart() Phương thức xóa khoảng trắng từ đầu chuỗi và trả về một chuỗi mới. Có nghĩa là trimStart() xoá những ký tự space bên trái mà không làm thay đổi chuỗi gốc.

Promise + gì

promise + gì

Copy a string to the clipboard

Copy a string to the clipboard. Only works as a result of user action (i.e. inside a click event listener).

Tránh viết biến có phạm vi global

Đôi khi bạn cần phải viết một tập lệnh trực tiếp trên trang. Cần lưu ý rằng trong code của bạn vô tình khai báo một biến toàn cầu. Vì phạm vi toàn cầu phức tạp hơn nên việc tìm kiếm chậm hơn rất nhiều