Files
30-seconds-of-code/static-parts/README-start.md
2018-09-22 10:58:26 +03:00

3.8 KiB

Logo

30 seconds of code

License npm Downloads npm Version Gitter chat PRs Welcome Travis Build Codacy Badge Maintainability js-semistandard-style Known Vulnerabilities ProductHunt

Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

Sponsored by DigitalOcean

  • Use Ctrl + F or command + F to search for a snippet.
  • Contributions welcome, please read the contribution guide.
  • Snippets are written in ES6, use the Babel transpiler to ensure backwards-compatibility.
  • You can import these snippets into your text editor of choice (VSCode, Atom, Sublime) using the files found in this repo.
  • You can import these snippets into Alfred 3, using this file.

Package

⚠️ NOTICE: A few of our snippets are not yet optimized for production (see disclaimers for individual snippet issues).

You can find a package with all the snippets on npm.

# With npm
npm install 30-seconds-of-code

# With yarn
yarn add 30-seconds-of-code

CDN links

Details

Browser

IMPORTANT: replace the src with the full version link and desired target spec (such as ES5 minified)):

<script src="https://unpkg.com/30-seconds-of-code"></script>
<script>
  _30s.average(1, 2, 3);
</script>

Node

// CommonJS
const _30s = require('30-seconds-of-code');
_30s.average(1, 2, 3);

// ES Modules
import _30s from '30-seconds-of-code';
_30s.average(1, 2, 3);

To import snippets directly:

// CommonJS
const { average } = require('30-seconds-of-code');
average(1, 2, 3);

// ES Modules
import { average } from '30-seconds-of-code';
average(1, 2, 3);

Table of Contents