How Does Node.js Resolve Modules from node_modules?
Node.js walks up parent folders looking for node_modules, then picks a file using exports or main. Learn the rules and how to debug them.
466 posts about JavaScript: questions with answers, tutorials and articles, newest first.
Node.js walks up parent folders looking for node_modules, then picks a file using exports or main. Learn the rules and how to debug them.
Learn the main ways to convert a number to a string in JavaScript, when each one fits, and how to control decimals and locale formatting.
The React component tree is the nested hierarchy of components in your app. See how React renders it, passes props down it and re-renders branches after state changes.
HTML data attributes store custom values on any element. See the naming rules, how to read and write them in JavaScript and CSS, and common pitfalls.
Node.js loads each module once and reuses its exports. See how require.cache works, how to clear it, and how ES modules differ.
Compare Number(), parseInt(), parseFloat() and the unary plus for converting strings to numbers, and see how to check for NaN safely.
Use the React children prop to build wrapper and layout components, add extra slots with named props, and type children in TypeScript.
__dirname is not defined in ES modules. Use import.meta.dirname and import.meta.filename, or fileURLToPath with import.meta.url on older Node.js.
A Symbol is a unique primitive value. Learn how to create one, use it as an object key and hook into the language with well-known symbols.
Pass an object with camelCase keys to the style prop to apply inline styles in React, and learn when CSS classes are the better choice.
Set type module in package.json so .js files become ES modules. Learn how .mjs and .cjs override it and how to fix errors after switching.
A practical guide to the modular AWS SDK for JavaScript v3: clients, commands, credentials, S3 and DynamoDB examples, pagination and v2 migration.
BigInt stores whole numbers of any size exactly. Learn how to create and use it, its limits with JSON and Math, and when to prefer Number.
JSX uses className because class is a reserved JavaScript word. Learn how to build dynamic class lists and other renamed attributes.
Compare CommonJS and ES modules in Node.js: syntax, sync versus async loading, live bindings, interoperability and a migration checklist.
0.1 + 0.2 gives 0.30000000000000004 because binary floats cannot store those decimals exactly. Learn the cause and the reliable fixes.
React fragments return several elements without an extra wrapper node. Learn the short and keyed forms and when to use them.
Enable ES modules with .mjs or type module, then use named and default exports, dynamic import and top-level await. Includes common error fixes.
Learn which characters a JavaScript variable name may use, which words are reserved and which naming conventions keep your code readable.
Use default and named exports to share React components between files, and fix the usual import errors with correct paths.