'how to check kind of response in javascript? [duplicate]

I'm using pdfjs-dist, to extract text from pdf, how to check what kind of response, is it a promise, some kind of iterator or enumerator is returned from this call . the problem i'm having is , when i iterate over each page and write it to a file with filestream , it works but if i save it to buffer and try to write it to a file, the library throws an error , that doesn't make sense =>

var result = Buffer.from(textContent, 'utf8');

var textContent = page.getTextContent();

how to test, what kind of object textContent is?

  var pdf = pdfjsLib.getDocument('/.sample.pdf');
  var maxPages = pdf.maxNumPages;
  var page = pdf.getPage(1);
  var textContent = page.getTextContent();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source