Callback in javascript

callback,tipjs

Callback in javascript

const fs = require('fs')
fs.readFile('/etc/passwd', (err, data) => {
  if (err) {
    console.error(err)
    return
  }
  console.log(data.toString())
})

Sử dụng callback rất hạn chế ví dụ :

fs.readFile(fileA, function (err, data) {
  fs.readFile(fileB, function (err, data) {
    // ...
  })
}

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

try/catch es10

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

Remove item in array javascript es6

Những bạn nào mà đã sử dụng ES6 một thời gian rồi thì có thể sử dụng method array.filter()

group by property javascript use reduce

group by property javascript use reduce

Rest Operator for Objects

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.

Hàm lày ngày trong tuần javascript

Hàm lày ngày trong tuần javascript