Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modern JavaScript #4

Open
coryhouse opened this issue Apr 18, 2018 · 0 comments
Open

Modern JavaScript #4

coryhouse opened this issue Apr 18, 2018 · 0 comments

Comments

@coryhouse
Copy link
Owner

coryhouse commented Apr 18, 2018

Modern JavaScript

ES Modules

  • ES modules vs CommonJS Simple example - Video
  • Imports
    • Named imports
    • Wildcard imports
    • Aliasing imports via as
    • Dynamic import
  • Exports
    • Default exports
    • Export * from a module
    • Exporting multiple functions at the bottom of the file (looks like an object, but technically isn't).
  • Barrel pattern
  • Show what these look like in Babel
  • ES modules must be statically analyzable (for tree shaking, autocomplete, and compile-time checks like eslint-plugin-import 👍)

Debugging

  • Use debugger to pause
  • console.table to display object in table
  • console.timer/console.timerEnd to check perf
  • console.assert to log a specific message to the console if an expected value isn't true
  • console.count/console.countReset to count the number of times a certain string has been logged.
  • Visual examples of the console features above

Native iterators

Don't confuse these!

  • for...of - Loop over iterables (arrays, strings, and array-like arguments.
  • for...in - Iterate over object properties

Functional Approaches

Copying Objects and Immutable data Structures

Async Patterns

  • Async patterns
    • Callbacks
    • Promises - A promise is a container that you get immediately for a value that you get eventually. Objects that represent the outcome of an event that may not yet have occurred.
      • Promise.all
      • Promise.race - Useful for timing out requests after x seconds.
      • Declare catch or it may swallow exceptions!
      • finally was added in ES2018 - always runs, regardless of resolve or rejection.
    • allSettled - Like promises.all, but the .then runs after all promises are settled, regardless of resolved or rejected.
    • Async/Await
  • Async cheatsheet

Regex

Other Patterns

Summary

@coryhouse coryhouse mentioned this issue Apr 18, 2018
13 tasks
@coryhouse coryhouse changed the title Modern JS with React Modern JS Apr 18, 2018
@coryhouse coryhouse changed the title Modern JS Modern JavaScript Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant