How much Javascript do you need to know to learn React?
Published: 2022-12-27 18:22:56

---
title: How much Javascript do you need to know to learn React?
published: true
date: 2022-12-27 00:00:00 UTC
tags: 
canonical_url: https://www.frontendundefined.com/posts/answers/how-much-javascript-react/
---

You know that [you need to know Javascript](https://www.frontendundefined.com/posts/answers/need-javascript-react) to use React. But how much Javascript should you know? Do you need to learn every concept and master it or can you learn a few basic concepts and then jump into React?

In the long term, the more Javascript you know the better. It is the primary programming language of the web and is crucial fundamental knowledge that will help you understand and use frontend frameworks and tools. Not having a good grasp of Javascript will constantly bother you as you struggle to understand why some code doesn't work.

But realistically, only a subset of Javascript concepts are commonly used with React. So knowing this subset should be sufficient for you to start learning React. If you are not comfortable with Javascript, you might have to go back to it repeatedly when you struggle with certain concepts.

So here are the Javascript concepts that you must know before learning React. This is not a complete list but it should give you a good idea of what you should know.

## Concepts that you should definitely know before learning React

If you don't know the following concepts, you will really struggle to understand React.

### Programming basics
  - Statements
  - Variables
  - Loops (e.g. while, for)
  - Mathematical (e.g. +, -) and logical operators (e.g. >, <, ===)
  - Conditional branching (e.g. if, ? operator)
  - Functions (including arrow functions)

### Data structure basics
  - Strings and string methods (e.g. indexOf, slice, substr)
  - Objects and object methods (e.g. Object.keys, Object.entries)
  - Arrays and array methods (e.g. map, reduce, find, sort, push, unshift, includes)

## Concepts that you need to know but could skip for a while

You might be able to start with React without these concepts but not knowing them will limit what you can do.

### Promises and asynchronous programming (i.e. async / await)
Websites built with React usually need to download data from a server. The most basic way\* to do this is with the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) which uses Promises and so you need to know how to work with them. Other data fetching methods tend to be asynchronous as well.

### Classes
Most React components created nowadays are Function components. But before [React hooks](https://reactjs.org/docs/hooks-intro.html) were introduced, most components were Class components. While you could avoid writing Class components now with by using React hooks, older React codebases still have many Class components.

### Newer Javascript syntactic sugar
Javascript is constantly evolving as a language with new concepts, operators and built in methods being added. There are several newer Javascript features that allow you to write code in a shorter, easier way. These features are commonly referred to as [syntactic sugar](https://en.wikipedia.org/wiki/Syntactic_sugar) and while you can achieve the same result without the older, basic syntax, they can make it a lot easier to write code. The following are the most useful for working with React.
    - [Destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)
    - [Optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining)

<sub>*Perhaps the most basic way of doing data fetching is with the older <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest">XMLHttpRequest API</a> but it is more cumbersome and the Fetch API is more commonly used</sub>