Learn in Public
  • Initial page
  • NOTES
    • Data Structures
      • Use cases
    • System Design
    • Angel Investing
    • Blockchain
      • Blockchain Interoperability
      • Consensus Algorithm
      • Wallet
      • dApps
    • Brain-computer interface
    • Cognitive Science
      • Memory
      • Neuroeconomics
    • JavaScript
      • Date
      • 📚Untitled
      • Basics
      • Front-end Interview Questions
      • JS Snippets
    • Machine Learning
      • OpenAI
    • MongoDB
    • GraphQL
    • TypeScript
    • UI / UX
    • Design Systems
    • Web Development
      • React
        • File Structure
        • Hooks 🎣
        • Next.js
      • Fetch API
      • Deployment
      • Accessibility
      • DNS Settings
      • css
        • CSS Structure
      • Pretty Website
      • Design Tools
      • Snippets
    • Remote
    • Flight Pricing
    • Mental Model
    • Surveillance
    • Web optimization
    • Archive
      • Cannabis
Powered by GitBook
On this page
  • Variable declarations
  • Array
  • Object
  • Promises
  • Currying

Was this helpful?

  1. NOTES

JavaScript

Type

MDN

Array

Date

Object

String

JSON

Set

RegExp

Destructuring Assignment

const

let

export

Variable declarations

var

  • function scoped

  • can be redeclared and updated

  • hoisted and initialized with undefined as a value

let

  • block scoped

  • declaring in a for loop, inside an if or in a plain block is not going to let the variable "escape" the block

  • only use let to reassign the variable

  • while let and const are hoisted but not initialized

const

  • immutable

  • block-scoped

  • default to const

Array

Object

Promises

When you go to a restaurant, the hostess gives you a buzzer for your table. When the table is ready, the buzzer buzzes. You respond by sitting at the table.

The buzzer is a promise. It buzzes when the promise resolves, or is ready. The buzz is your handler.

var buzzer = new Promise();

fetchTableAsync(hostess => {
    var table = hostess.prepareTable();
    hostess.informServer();
    buzzer.resolve(table);
});

buzzer.then(table => me.sitAtTable(table));

Currying

Currying is a process to reduce functions of more than one argument to functions of one argument with the help of lambda calculus.

multiply = (n, m) => (n * m)
multiply(3, 4) === 12 // true

curryedMultiply = (n) => ( (m) => multiply(n, m) )
triple = curryedMultiply(3)
triple(4) === 12 // true
PreviousNeuroeconomicsNextDate

Last updated 6 years ago

Was this helpful?

https://sdras.github.io/array-explorer/
https://flaviocopes.com/javascript-array/
https://sdras.github.io/object-explorer/
https://codepen.io/thonly/pen/JOdwKM
https://github.com/wbinnssmith/awesome-promises
https://blog.benestudio.co/currying-in-javascript-es6-540d2ad09400
MDN
MDN
MDN
MDN
MDN
MDN
MDN
MDN
MDN
MDN
MDN