Signup to the waiting list!
- Block Scoping
- Function Scoping
- Lexical Scoping
- Pure function
- Side effect
- Strict mode
- Tree Shaking
Code is asynchronous when you initiate something, forget about it, and when the result is ready you get it back without having to wait for it. The typical example is an AJAX call, which might take even seconds and in the meantime you complete other stuff, and when the response is ready, the callback function gets called. Promises and async/await are the modern way to handle async.
if statement contains a block, a
for loop contains a block.
A callback is a function that’s invoked when something happens. A click event associated to an element has a callback function that’s invoked when the user clicks the element. A fetch request has a callback that’s called when the resource is downloaded.
With Function Scoping, any variable defined in a function is visible and accessible from inside the whole function.
A variable is immutable when its value cannot change after it’s created. A mutable variable can be changed. The same applies to objects and arrays.
Lexical Scoping is a particular kind of scoping which means that the value of a variable is defined by its position when it’s written. Not when it’s called, which is something that happens with the alternative, dynamic scoping (used in some other programming languages).
A function that has no side effects (does not modify external resources), and its output is only determined by the arguments. You could call this function 1M times, and given the same set of arguments, the output will always be the same.
let declaration allows you to reassign a variable indefinitely. With
const declarations you effectively declare an immutable value for strings, integers, booleans, and an object that cannot be reassigned (but you can still modify it through its methods).
Scope is, referred to a variable, in what portion of a program that variable is visible.
const have block scoping, which determines a differnet scope from values defined using
var, which have function scoping.
Scoping is how a programming language determines the scope of the variables and functions. We can for example have block scoping, function scoping, lexical scoping.
A shim is a little wrapper around a functionality, or API. It’s generally used to abstract something, pre-fill parameters or add a polyfill for browsers that do not support some functionality. You can consider it like a compatibility layer.
A side effect is when a function interacts with some other function or object outside it. Interaction with the network or the file system, or with the UI, are all side effects.
State usually comes into play when talking about Components. A component can be stateful if it manages its own data, or stateless if it doesn’t.
A stateful component, function or class manages its own state (data). It could store an array, a counter or anything else.
A stateless component, function or class is also called dumb because it’s incapable of having its own data to make decisions, so its output or presentation is entirely based on its arguments. This implies that pure functions are stateless. Note: in React, what we once called stateless components are now called function components because hooks give them the ability to use state.
Tree shaking means removing “dead code” from the bundle you ship to your users. If you add some code that you never use in your import statements, that’s not going to be sent to the users of your app, to reduce file size and loading time.
More js tutorials:
- The Complete ECMAScript 2015-2019 Guide
- A list of sample Web App Ideas
- Introduction to Unicode and UTF-8
- Introduction to ES Modules
- Introduction to CommonJS
- A Moment.js tutorial
- The ES6 Guide
- The ES2016 Guide
- The ES2017 Guide
- The ES2018 Guide
- How to use Async and Await with Array.prototype.map()
- Async vs sync code
- HTML Canvas API Tutorial
- What is a Single Page Application?
- An introduction to WebAssembly
- Introduction to JSON
- The JSONP Guide
- Should you use or learn jQuery in 2020?
- Introduction to PeerJS, the WebRTC library
- Work with objects and arrays using Rest and Spread
- The TypeScript Guide
- Loosely typed vs strongly typed languages
- The node_modules folder size is not a problem. It's a privilege
- The String replace() method
- The String search() method
- The ES2019 Guide
- The String charAt() method
- The String charCodeAt() method
- The String codePointAt() method
- The String concat() method
- The String endsWith() method
- The String includes() method
- The String indexOf() method
- The String lastIndexOf() method
- The String localeCompare() method
- The String match() method
- The String normalize() method
- The String padEnd() method
- The String padStart() method
- The String repeat() method
- The String slice() method
- The String split() method
- The String startsWith() method
- The String substring() method
- The String toLocaleLowerCase() method
- The String toLocaleUpperCase() method
- The String toLowerCase() method
- The String toString() method
- The String toUpperCase() method
- The String trim() method
- The String trimEnd() method
- The String trimStart() method
- The String valueOf() method
- The Number isInteger() method
- The Number isNaN() method
- The Number isSafeInteger() method
- The Number parseFloat() method
- The Number parseInt() method
- The Number toString() method
- The Number valueOf() method
- The Number toPrecision() method
- The Number toExponential() method
- The Number toLocaleString() method
- The Number toFixed() method
- The Number isFinite() method
- The Object assign() method
- The Object create() method
- The Object defineProperties() method
- The Object defineProperty() method
- The Object entries() method
- The Object freeze() method
- The Object getOwnPropertyDescriptor() method
- The Object getOwnPropertyDescriptors() method
- The Object getOwnPropertyNames() method
- The Object getOwnPropertySymbols() method
- The Object getPrototypeOf() method
- The Object is() method
- The Object isExtensible() method
- The Object isFrozen() method
- The Object isSealed() method
- The Object keys() method
- The Object preventExtensions() method
- The Object seal() method
- The Object setPrototypeOf() method
- The Object values() method
- The Object hasOwnProperty() method
- The Object isPrototypeOf() method
- The Object propertyIsEnumerable() method
- The Object toLocaleString() method
- The Object toString() method
- The Object valueOf() method
- How to rename fields when using object destructuring
- How to send urlencoded data using Axios
- How to upload a file using Fetch
- How to use top-level await in ES Modules
- How to send the authorization header using Axios
- How to remove all the node_modules folders content
- How to get the first n items in an array in JS
- How to divide an array in multiple equal parts in JS
- How to load an image in an HTML canvas
- How to write text into to an HTML canvas
- How to fix the TypeError: Cannot assign to read only property 'exports' of object '#<Object>' error
- How to create an exit intent popup
- How to check if an element is a descendant of another
- How to force credentials to every Axios request
- Gatsby, how to change the favicon
- Loading an external JS file using Gatsby
- Parcel, how to fix the `regeneratorRuntime is not defined` error
- Object destructuring with types in TypeScript
- The Deno Handbook: a concise introduction to Deno 🦕
- Event bubbling and event capturing
- event.stopPropagation vs event.preventDefault() vs. return false in DOM events
- In which ways can we access the value of a property of an object?
- What's the difference between a method and a function?
- The importance of timing when working with the DOM
- Introduction to XState
- How to handle promise rejections
- How I fixed a "cb.apply is not a function" error while using Gitbook
- Gatsby, fix the "cannot find module gatsby-cli/lib/reporter" error