2

I often see the + operator in examples like this. I don't quite understand what plus means here?

const contentLength = +response.headers.get('Content-Length');

I am studying the fetch-progress topic, and I don’t understand the + in the line I indicated.

tdy
  • 36,675
  • 19
  • 86
  • 83
  • 2
    Shorthand to convert the value to a numeric type using `Number()`: https://stackoverflow.com/a/69470467/519413 – Rory McCrossan Mar 02 '23 at 20:05
  • 2
    Things like this can be tested in the browser console or Node REPL. Type in something like `+ "1234"` and see what comes back. – Dave Newton Mar 02 '23 at 20:09

0 Answers0