Promise Vs Callback function in Javascript

promise-vs-callback Difference between a promise and a callback in Javascript DasJs

Difference between a promise and a callback in Javascript:

Let's start the battle. Promise Vs Callback

Everything you can do with promises you can do with callbacks.
The deep reason why promises are often better is that
the combination of multiple promises just works, while combining multiple callbacks often doesn't.

Check this link: Promises: A complete explanation of modern JavaScript

For the example you gave of a single callback versus a single promise, it's true there's no significant difference. It's when you have a combination of callbacks (Callback Hell) versus a combination of promises that the promise-based code tends to look much nicer.

Let's check out an example of Callback Hell:

fs.readdir(source, function (err, files) {
  if (err) {
    console.log('Error finding files: ' + err)
  } else {
    files.forEach(function (filename, fileIndex) {
      gm(source + filename).size(function (err, values) {
        if (err) {
          console.log('Error identifying file size: ' + err)
        } else {
          console.log(filename + ' : ' + values)
          aspect = (values.width / values.height)
          widths.forEach(function (width, widthIndex) {
            height = Math.round(width / aspect)
            console.log('resizing ' + filename + 'to ' + height + 'x' + height)
            this.resize(width, height).write(dest + 'w' + width + '_' + filename, function(err) {
              if (err) console.log('Error writing file: ' + err)

It's not easily maintainable.

Promise has an advantage over callback is by the uniform handling of return values and uncaught exceptions. With callbacks, how an exception gets handled may depend entirely on which of the many nested callbacks threw it.