-2

Example :

const {http} = require('http');

I have seen something about "destructing" and have read some resources about that, but I am still very confused about what it actually does.

Balocre
  • 175
  • 2
  • 10

1 Answers1

2

It extracts that property from the object.
The meaning of it is exacly the same as writing this:

const http = require('http').http;

You can read more about object destructuring (and destructuring in general) here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring

Isti115
  • 2,418
  • 3
  • 29
  • 35