Files
30-seconds-of-code/static-parts/README-start.md
2018-01-03 18:11:19 +01:00

2.9 KiB

Logo

30 seconds of code

License npm Downloads npm Version Gitter chat PRs Welcome Travis Build Insight.io js-semistandard-style ProductHunt

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

  • 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

⚠️ WARNING: Snippets are not production ready.

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

npm install 30-seconds-of-code

CDN links

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