SlideShare a Scribd company logo
3
Most read
ReactJs : Tutorial-02 – ES6
ES6 – ECMAScript 6
Standardized JavaScript
Version 6 in 2015 (ECMAScript 2015)
ReactJs uses ES6
New Features:
o Classes
o Arrow Functions
o Variables (let, const, var)
ES6 – Class:
A class is a type of function.
Property in constructor.
Example:
class Car {
constructor(name) {
this.brand = name;
}
}
mycar = new Car("BMW");
Method in Classes
class Car {
constructor(name) {
this.brand = name;
}
present() {
return 'I have a ' + this.brand;
}
}
mycar = new Car("Ford");
mycar.present();
Output
I have a Ford
ReactJs : Tutorial-02 – ES6
Class Inheritance
To create a class inheritance, use the extends keyword.
A class created with a class inheritance inherits all the methods from another class:
Example
Create a class named "Model" which will inherit the methods from the "Car" class:
class Car {
constructor(name) {
this.brand = name;
}
present() {
return 'I have a ' + this.brand;
}
}
class Model extends Car {
constructor(name, mod) {
super(name);
this.model = mod;
}
show() {
return this.present() + ', it is a ' + this.model
}
}
mycar = new Model("Ford", "Mustang");
mycar.show();
ReactJs : Tutorial-02 – ES6
Arrow Functions
Arrow functions were introduced in ES6.
Arrow functions allow us to write shorter function syntax:
Before:
hello = function() {
return "Hello World!";
}
With Arrow Function:
hello = () => {
return "Hello World!";
}
Arrow Functions Return Value by Default:
hello = () => "Hello World!";
Arrow Function With Parameters:
hello = (val) => "Hello " + val;
Arrow Function Without Parentheses:
hello = val => "Hello " + val;
ReactJs : Tutorial-02 – ES6
Variables
Before ES6 there were only one way of defining your variables: with the var keyword.
Now, with ES6, there are three ways of defining your variables: var, let, and const.
 var has a function scope, not a block scope.
 let has a block scope.
 const has a block scope. const is a variable that once it has been created, its value can never
change.

More Related Content

PDF
React js t6 -lifecycle
PDF
React js t4 - components
PDF
React js t5 - state
PDF
React js t1 - introduction
PDF
React js t8 - inlinecss
PDF
React js t7 - forms-events
PDF
Introduction to React Hooks
PDF
React js use contexts and useContext hook
React js t6 -lifecycle
React js t4 - components
React js t5 - state
React js t1 - introduction
React js t8 - inlinecss
React js t7 - forms-events
Introduction to React Hooks
React js use contexts and useContext hook

What's hot (20)

PPTX
React-JS Component Life-cycle Methods
PPTX
Running SQL from a Groovy Event Handler in Agile PLM
PPTX
React hooks
ODP
Introduction to Angular 2
PPTX
Angular 2
PPTX
React js
PPTX
Pluginkla2019 - React Presentation
PDF
Workshop 20: ReactJS Part II Flux Pattern & Redux
PDF
Workshop 19: ReactJS Introduction
PDF
React custom renderers
PPTX
React - Start learning today
PDF
React: JSX and Top Level API
ODP
Docker - An Introduction
PPTX
PDF
React hooks Episode #1: An introduction.
PPTX
React and Flux life cycle with JSX, React Router and Jest Unit Testing
PPT
Spring AOP
PDF
[Fevr] Can't live if livin' is without rendering
ODP
Introduction to ReactJS
PDF
Angular2 with TypeScript
React-JS Component Life-cycle Methods
Running SQL from a Groovy Event Handler in Agile PLM
React hooks
Introduction to Angular 2
Angular 2
React js
Pluginkla2019 - React Presentation
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 19: ReactJS Introduction
React custom renderers
React - Start learning today
React: JSX and Top Level API
Docker - An Introduction
React hooks Episode #1: An introduction.
React and Flux life cycle with JSX, React Router and Jest Unit Testing
Spring AOP
[Fevr] Can't live if livin' is without rendering
Introduction to ReactJS
Angular2 with TypeScript
Ad

Similar to React js t3 - es6 (20)

PPTX
ReactJS.pptx
PPTX
Intro to ES6 and why should you bother !
PPTX
Getting started with ES6
PPTX
React & Redux JS
PPTX
Java script basics
PDF
OOPS JavaScript Interview Questions PDF By ScholarHat
PPTX
Workshop JavaScript ES6+
PDF
js notes apni kaksha ahsgsggdgsgsgsgsgsgsgs
DOCX
OOP and C++Classes
PDF
Advanced JavaScript - Internship Presentation - Week6
KEY
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
PDF
Java 17
PDF
EcmaScript 6 - The future is here
PDF
SproutCore and the Future of Web Apps
PDF
MCS First Year JavaScript ES6 Features.pdf
PDF
JavaScript - new features in ECMAScript 6
PPTX
Modern JS with ES6
PDF
Javascript Exercises
PPTX
classes object fgfhdfgfdgfgfgfgfdoop.pptx
PPTX
ECMAScript 2015
ReactJS.pptx
Intro to ES6 and why should you bother !
Getting started with ES6
React & Redux JS
Java script basics
OOPS JavaScript Interview Questions PDF By ScholarHat
Workshop JavaScript ES6+
js notes apni kaksha ahsgsggdgsgsgsgsgsgsgs
OOP and C++Classes
Advanced JavaScript - Internship Presentation - Week6
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Java 17
EcmaScript 6 - The future is here
SproutCore and the Future of Web Apps
MCS First Year JavaScript ES6 Features.pdf
JavaScript - new features in ECMAScript 6
Modern JS with ES6
Javascript Exercises
classes object fgfhdfgfdgfgfgfgfdoop.pptx
ECMAScript 2015
Ad

More from Jainul Musani (20)

PDF
Core Java Interface Concepts for BCA Studetns
PDF
Java Abstract and Final Class for BCA students
PDF
Java Collection Framework for BCA Students
PDF
Simple Calculator using JavaFx a part of Advance Java
PDF
JavaFx Introduction, Basic JavaFx Architecture
PDF
ASP.NET 2010, WebServices Full Example for BCA Students
PDF
Palindrome Programme in PHP for BCA students
PDF
Leap Year Program in PHP for BCA students
PDF
"PHP and MySQL CRUD Operations for Student Management System"
PDF
Python: The Versatile Programming Language - Introduction
PPTX
Python a Versatile Programming Language - Introduction
PDF
React js t2 - jsx
PPTX
ExpressJs Session01
PPTX
NodeJs Session03
PPTX
NodeJs Session02
PPTX
Nodejs Session01
PDF
Java exercise1
PPSX
Fundamentals of JDBC
PPT
Core Java Special
PDF
Core Java Special
Core Java Interface Concepts for BCA Studetns
Java Abstract and Final Class for BCA students
Java Collection Framework for BCA Students
Simple Calculator using JavaFx a part of Advance Java
JavaFx Introduction, Basic JavaFx Architecture
ASP.NET 2010, WebServices Full Example for BCA Students
Palindrome Programme in PHP for BCA students
Leap Year Program in PHP for BCA students
"PHP and MySQL CRUD Operations for Student Management System"
Python: The Versatile Programming Language - Introduction
Python a Versatile Programming Language - Introduction
React js t2 - jsx
ExpressJs Session01
NodeJs Session03
NodeJs Session02
Nodejs Session01
Java exercise1
Fundamentals of JDBC
Core Java Special
Core Java Special

Recently uploaded (20)

PPTX
Cell Structure & Organelles in detailed.
PPTX
master seminar digital applications in india
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Pharma ospi slides which help in ospi learning
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
01-Introduction-to-Information-Management.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
Cell Structure & Organelles in detailed.
master seminar digital applications in india
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
2.FourierTransform-ShortQuestionswithAnswers.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Final Presentation General Medicine 03-08-2024.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
VCE English Exam - Section C Student Revision Booklet
Final Presentation General Medicine 03-08-2024.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Computing-Curriculum for Schools in Ghana
Microbial diseases, their pathogenesis and prophylaxis
Pharma ospi slides which help in ospi learning
FourierSeries-QuestionsWithAnswers(Part-A).pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Anesthesia in Laparoscopic Surgery in India
01-Introduction-to-Information-Management.pdf
O5-L3 Freight Transport Ops (International) V1.pdf

React js t3 - es6

  • 1. ReactJs : Tutorial-02 – ES6 ES6 – ECMAScript 6 Standardized JavaScript Version 6 in 2015 (ECMAScript 2015) ReactJs uses ES6 New Features: o Classes o Arrow Functions o Variables (let, const, var) ES6 – Class: A class is a type of function. Property in constructor. Example: class Car { constructor(name) { this.brand = name; } } mycar = new Car("BMW"); Method in Classes class Car { constructor(name) { this.brand = name; } present() { return 'I have a ' + this.brand; } } mycar = new Car("Ford"); mycar.present(); Output I have a Ford
  • 2. ReactJs : Tutorial-02 – ES6 Class Inheritance To create a class inheritance, use the extends keyword. A class created with a class inheritance inherits all the methods from another class: Example Create a class named "Model" which will inherit the methods from the "Car" class: class Car { constructor(name) { this.brand = name; } present() { return 'I have a ' + this.brand; } } class Model extends Car { constructor(name, mod) { super(name); this.model = mod; } show() { return this.present() + ', it is a ' + this.model } } mycar = new Model("Ford", "Mustang"); mycar.show();
  • 3. ReactJs : Tutorial-02 – ES6 Arrow Functions Arrow functions were introduced in ES6. Arrow functions allow us to write shorter function syntax: Before: hello = function() { return "Hello World!"; } With Arrow Function: hello = () => { return "Hello World!"; } Arrow Functions Return Value by Default: hello = () => "Hello World!"; Arrow Function With Parameters: hello = (val) => "Hello " + val; Arrow Function Without Parentheses: hello = val => "Hello " + val;
  • 4. ReactJs : Tutorial-02 – ES6 Variables Before ES6 there were only one way of defining your variables: with the var keyword. Now, with ES6, there are three ways of defining your variables: var, let, and const.  var has a function scope, not a block scope.  let has a block scope.  const has a block scope. const is a variable that once it has been created, its value can never change.