Table of Contents
What is react
What is es6
Home Web Front-end Front-end Q&A What are react and es6

What are react and es6

Oct 26, 2022 pm 05:29 PM
react javascript es6

react is a declarative, efficient and flexible JavaScript development framework launched by Facebook for building user interfaces; it provides programmers with a model in which sub-components cannot directly affect outer components. When data changes Efficient updates to HTML documents and clean separation between components in modern single-page applications. es6 is the next version standard of JavaScript. Its goal is to make the JavaScript language can be used to write complex large-scale applications and become an enterprise-level development language.

What are react and es6

The operating environment of this tutorial: windows7 system, ECMAScript 6&&react18 version, Dell G3 computer.

What is react


react.js is a JavaScript development framework launched by Facebook for building user interfaces.

React is a declarative, efficient and flexible JavaScript library for building user interfaces. React allows you to combine short, independent code snippets into complex UI interfaces. These code snippets are called "components".

Because the design idea of ​​React is extremely unique, it is a revolutionary innovation, has outstanding performance, and the code logic is very simple. Therefore, more and more people are beginning to pay attention to and use it, thinking that it may be the mainstream tool for web development in the future.

What are react and es6

#React is an open source JavaScript library that provides views of data rendered into HTML. React views are typically rendered using components that contain other components specified in custom HTML tags. React provides programmers with a model in which child components cannot directly affect outer components, efficient updates to HTML documents when data changes, and clean separation between components in modern single-page applications.

The advantages of React are:

  • More suitable for large applications and better testability

  • Web and mobile native APP take all

  • A larger ecosystem, more support and easy-to-use tools

  • More suitable for medium and large projects

What is es6


es6 full name is ECMAScript6 (the 6th version of ECMAScript), which was released in 2015 The JavaScript language standard officially released in June 2015 is officially called ECMAScript 2015 (ES2015).

ECMAScript 6 has basically become the industry standard, and its popularity is much faster than ES5. The main reason is that modern browsers support ES6 very quickly, especially Chrome and Firefox browsers, which already support Most features in ES6.

Since then, ECMA Script has released a major version every year to add some important features, which we call ES6.

What are react and es6

Understand the relationship between ES and JS

ES = ECMAScript is a 'standard' for dynamic scripting languages, JS = JavaScript is the standard, default, and mainstream 'implementation' of ES. Due to trademark rights issues, the language standard formulated by the European Computer Association cannot be called JS, but can only be called ES;

The purpose of the new ES6 standard is: JS can be used to develop large-scale web applications and become an enterprise-level development language. The enterprise-level development language is: suitable for modular development and has good dependency management;

Why should you learn ES6? What is ES6 used for?

ES5 cannot meet the current situation where the front-end is becoming more and more complex and huge. It can be said to be outdated. ES6 is an enhancement and upgrade to ES5.

1. Mainstream browsers have fully supported ES6

2. Newer front-end frameworks in the industry have fully used ES6 syntax

3. WeChat applet , uni-app, etc. are all based on ES6 syntax

4. Starting from employment, small and medium-sized companies, full stack, one more skill on the resume, and the trial period can also get started faster.

Variable

  • let
    Only one let variable can be declared in a scope. If the child If a let variable is also declared in the scope, it will not affect the let variable in the parent scope.
  • var
    Multiple var variables can be declared in one scope. If a var variable is also declared in the child scope, it will also affect the var variable in the parent scope.
  • const
    Constant, equivalent to final, cannot be modified.
  • global
    Variables that do not declare a variable type default to global variables (window attributes).

Object-oriented

  • Principle
    The object-oriented features of JavaScript are based on prototypes and constructors, which are different from the common ones based on classes. JavaScript does not provide language-level features of object inheritance, but does so through prototype copying.
  • Three methods of creating objects
  1. {pojo}(实例变量、实例方法、get、set) 
  2. function(实例变量、实例方法、prototype、apply、call) 
  3. class(实例变量、实例方法、prototype、extends、super)
Copy after login

prototype

Only functions and classes Only prototypes exist, and their significance lies in dynamically adding instance variables and instance methods and implementing inheritance.

Inheritance

  • ##call/apply In the inheritance relationship, the subclass applies to the parent This keyword should be used when passing parameters in a class
  • extends Used in inheritance relationships, A extends B, then A is the parent class of B
  • super ## This method of calling the parent class in the sub -category uses the keywords
  • ## ES5 inheritance method
  • # Next (prototype inheritance) constructor inheritance (inherited properties)). This method can avoid the disadvantages of being unable to implement multiple inheritance in prototype chain inheritance, being unable to pass parameters to the parent class constructor when creating a subclass instance, and also avoiding the disadvantages of being unable to inherit prototype properties/methods in constructor inheritance.
    function Person(name,age){                                             /* 父类 */
        this.name = name || 'father';                            //实例变量
        this.namesonF = this.nameson;
        this.age = age;
        this.talk = function(){alert("talk");};                 //实例方法
    };
    function Son(name){                                                     /* 子类 */
        this.nameson = name || 'son';
        // Person.call(this,'name',18);                          //继承:构造继承,复制父类的实例属性给子类,不能继承原型属性/方法
        Person.apply(this,['name',18]);                          //继承:构造继承,复制父类的实例属性给子类,不能继承原型属性/方法
    }
    // Son.prototype = new Person("zhangsan",19);                   //继承:原型链继承,父类的实例作为子类的原型,拷贝属性两次,不合理
    Son.prototype = Person.prototype;                            //继承:原型链继承,父类的实例作为子类的原型
    
    Person.prototype.publicParam="param1";                       //动态添加实例变量
    Person.prototype.talk=function(){alert("talk");}            //动态添加实例方法
    
    var son = new Son();                                         //实例化对象,调用构造函数(constructor)
    Copy after login
    ES6 inheritance method
  • ES6 inheritance creates a new way of writing, which is very similar to Java, Scala and other languages, and uses combined inheritance by default ( Prototype chain inheritance (inheriting prototypes) construct inheritance (inheriting properties)).
    class Point {
        constructor(x, y) {
            this.x = x;                                           //实例变量
            this.y = y;
        }
    }
    class Son extends Point {
        constructor(z, w) {
            super(z,w);
            this.z = z;                                           //实例变量
            this.w = w;
        }
    }
    var son = new Son(1,2);
    Copy after login

arrow functions Arrow function is a new syntax added in ES6, which is similar to Java's lambda and scala's functional expression. The syntax is very similar

    code
  • var single = a => console.log(a);
    var single = (a) => (console.log(a));
    var single = (a, b) => {console.log(a + b)};
    var single = (a, b) => {return a + b};
    Copy after login

template string Template String, new syntax for string concatenation

    Code
  • var templateStr = () => {
        var str1 = "adsf\nsdfa";
    
        var template1 = `<ul><li>first</li> <li>second</li></ul>`;
    
        var x = 1;
        var y = 2;
        var template2 = `${x} + ${y} = ${x + y}`;
    
        var template3 = `${lettest4()}`;
        console.log(str1)
        console.log(template1)
        console.log(template2)
        console.log(template3)
    }
    Copy after login

destructuring Reconstruction/deconstruction, syntax for variable interaction

    Code
  • var destructuring = () => {
        var [a,b,...c]=[1,2,3,4,5,6,7,8,9,10];
        let [temp="replaceString"] = ["tempString"];
        let [age2, [{name: fname},{age: fname2="replaceString"}]] = [20, [{name: &#39;qc&#39;},{}]];
        const [aa,bb,cc,dd,ee,ff]="hello";
    
        let {name="replaceName",age,id}={name:&#39;cursor&#39;,age:19,id:&#39;vc6dfuoc91vpdfoi87s&#39;};
        let {type:tipType,min:minNumber}={type:&#39;message&#39;,min:20};
        let {sin,cos,tan,log}=Math;
    
        var fun = function({x,y}={}){return [x,y];}
        fun({x:100,y:2});
    
        [a,b]=[b,a];                                        //交换
    
        var map = [1,2,3]
        var map=new Map();
        map.set("id","007");
        map.set("name","cursor");
        for(let [key,value] of map){}
        for(let [key] of map){}
        for(let [,value] of map){}
    
        var arr = [1,2,3,4]
        for(let val of arr){val}
    
    }
    Copy after login

arguments Actual parameters, variables added in ES6 to directly read parameters

    Code
  • function argumentsTest(a,b) { 
    	for(let val of arguments)
    		{console.log(val)
    	}
    }
    Copy after login
    [Related recommendations : javascript video tutorial

    , programming video

    The above is the detailed content of What are react and es6. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP, Vue and React: How to choose the most suitable front-end framework? PHP, Vue and React: How to choose the most suitable front-end framework? Mar 15, 2024 pm 05:48 PM

PHP, Vue and React: How to choose the most suitable front-end framework? With the continuous development of Internet technology, front-end frameworks play a vital role in Web development. PHP, Vue and React are three representative front-end frameworks, each with its own unique characteristics and advantages. When choosing which front-end framework to use, developers need to make an informed decision based on project needs, team skills, and personal preferences. This article will compare the characteristics and uses of the three front-end frameworks PHP, Vue and React.

Integration of Java framework and front-end React framework Integration of Java framework and front-end React framework Jun 01, 2024 pm 03:16 PM

Integration of Java framework and React framework: Steps: Set up the back-end Java framework. Create project structure. Configure build tools. Create React applications. Write REST API endpoints. Configure the communication mechanism. Practical case (SpringBoot+React): Java code: Define RESTfulAPI controller. React code: Get and display the data returned by the API.

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

How to get HTTP status code in JavaScript the easy way How to get HTTP status code in JavaScript the easy way Jan 05, 2024 pm 01:37 PM

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service

Vue.js vs. React: Project-Specific Considerations Vue.js vs. React: Project-Specific Considerations Apr 09, 2025 am 12:01 AM

Vue.js is suitable for small and medium-sized projects and fast iterations, while React is suitable for large and complex applications. 1) Vue.js is easy to use and is suitable for situations where the team is insufficient or the project scale is small. 2) React has a richer ecosystem and is suitable for projects with high performance and complex functional needs.

React's Role in HTML: Enhancing User Experience React's Role in HTML: Enhancing User Experience Apr 09, 2025 am 12:11 AM

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

React and the Frontend: Building Interactive Experiences React and the Frontend: Building Interactive Experiences Apr 11, 2025 am 12:02 AM

React is the preferred tool for building interactive front-end experiences. 1) React simplifies UI development through componentization and virtual DOM. 2) Components are divided into function components and class components. Function components are simpler and class components provide more life cycle methods. 3) The working principle of React relies on virtual DOM and reconciliation algorithm to improve performance. 4) State management uses useState or this.state, and life cycle methods such as componentDidMount are used for specific logic. 5) Basic usage includes creating components and managing state, and advanced usage involves custom hooks and performance optimization. 6) Common errors include improper status updates and performance issues, debugging skills include using ReactDevTools and Excellent

React vs. Vue: Which Framework Does Netflix Use? React vs. Vue: Which Framework Does Netflix Use? Apr 14, 2025 am 12:19 AM

Netflixusesacustomframeworkcalled"Gibbon"builtonReact,notReactorVuedirectly.1)TeamExperience:Choosebasedonfamiliarity.2)ProjectComplexity:Vueforsimplerprojects,Reactforcomplexones.3)CustomizationNeeds:Reactoffersmoreflexibility.4)Ecosystema

See all articles