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.
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.
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