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

snowflake là gì

snowflake là gì? Năm 2010, Twitter có nguồn mở Snowflake, một thuật toán tạo ID duy nhất trên toàn cầu được sử dụng bởi nhóm nội bộ của nó, được dịch thành Snowflake.

Ajax, call jQuery POST to node.js expressjs

Ajax, call jQuery POST to node.js expressjs

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.

Làm phẳng mảng dùng phương pháp đệ quy

Làm phẳng mảng dùng phương pháp đệ quy

Spread Operator for Objects

Using the spread operator during an Object declaration will assign the properties of the referenced Object to the new Object.