Node v18

· vhm's blog

# Features & Usage

# Prefix-only core modules

const os = require('node:os');
const path = require('node:path');

# Auto reload when change

1node --watch index.js

# Native fetch API

const res = await fetch('https://nodejs.org/api/documentation.json');
if (res.ok) {
  const data = await res.json();
  console.log(data);
}

# Experimental WebStreams API

Node.js now exposes the experimental implementation of the WebStream API on the global scope. This means the following APIs are now globally available:

# Array methods

# Examples:

const inputArray = [{v:1}, {v:2}, {v:3}, {v:4}, {v:5}];
inputArray.findLast((element) => element.v % 2 === 0);
// → {v:4}
inputArray.findLast((element) => element.v % 7 === 0);
// → undefined
inputArray.findLastIndex((element) => element.v % 2 === 0);
// → 3
inputArray.findLastIndex((element) => element.v % 7 === 0);
// → -1

# Refer: