- JS Introduction
- JS Introduction
- JS Comments
- JS Variables
- JS Datatypes
- JS Operators
- JS Type Conversions
- JS Control Flow
- JS Comparisons
- JS If else
- JS If else Ladder
- JS Ternary Operator
- JS Switch
- JS For Loop
- JS For In
- JS For Of
- JS While
- JS Do While
- JS Break & Continue
- JS Functions
- JS Function Declaration
- JS Function Parameters
- JS Return Statement
- JS Function Expressions
- JS Anonymous Functions
- JS Objects
- JS Objects
- JS Object Methods
- JS Object Constructors
- JS Object Destructuring
- JS Object Prototypes
- JS Map, Filter & Reduce
- JS ES6
- JS ES6
- JS let and const
- JS Arrow Functions
- JS Template Literals
- Destructuring Assignment
- JS Spread Operator
- JS Default Parameters
- JS Classes
- JS Inheritance
- JS Map
- JS Set
- JS Async
- JS Callbacks
- JS Asynchronous
- JS Promises
- JS Async/Await
- JS HTML DOM/BOM
- JS Document Object
- JS getElementbyId
- getElementsByClassName
- JS getElementsByName
- getElementsByTagName
- JS innerHTML
- JS outerHTML
- JS Window Object
- JS History Object
- JS Navigator Object
- JS Screen Object
JavaScript ES6 Features
- Major Update: JavaScript ES6, or ECMAScript 2015, represents a significant update to the JavaScript language.
- Enhancements: Introduces new syntax, features, and improvements to JavaScript.
- Readability and Expressiveness: Designed to enhance code readability, expressiveness, and maintainability.
- Modern Constructs: Provides developers with modern language constructs for building sophisticated web applications.
- Widespread Adoption: Widely adopted by developers and supported by modern JavaScript frameworks, libraries, and tools.
- Foundation for Future Versions: Serves as the foundation for subsequent versions of ECMAScript, enabling ongoing innovation in JavaScript development.
let and const
- let: Block-scoped variable declaration.
- const: Declares constants with immutable values.
Syntax:
let variableName = value;
const constantName = value;
Example:
let count = 10;
const PI = 3.14159;
Arrow Functions
- Provides a concise syntax for writing function expressions.
- Lexically binds this.
Syntax:
const functionName = (param1, param2) => {
// Function body
};
Example:
const sum = (a, b) => a + b;
Template Literals
- Allows string interpolation and multi-line strings.
Syntax:
const message = `Hello, ${name}!`;
Example:
const multiline = `Line 1
Line 2
Line 3`;
Destructuring Assignment
- Extracts values from arrays or objects into variables.
Syntax:
const { prop1, prop2 } = object;
const [ item1, item2 ] = array;
Example:
const person = { name: 'John', age: 30 };
const { name, age } = person;
Spread and Rest Operators
- Spread operator expands iterable elements.
- Rest parameter collects multiple function arguments into an array.
Syntax:
const newArray = [...array];
function myFunction(...args) { }
Example:
const numbers = [1, 2, 3];
const sum = (a, b, c) => a + b + c;
const result = sum(...numbers);
Enhanced Object Literals
- Shorthand property names and computed property names.
Syntax:
const obj = { property };
const obj = { [dynamicProperty]: value };
Example:
const name = 'John';
const obj = { name };
Classes
- Provides a more structured way to define objects and their behavior.
- Simplifies inheritance and object-oriented programming.
Syntax:
class MyClass {
constructor() { }
method() { }
}
Example:
class Person {
constructor(name) {
this.name = name;
}
}
Promises
- Represents the eventual completion or failure of an asynchronous operation.
Syntax:
const promise = new Promise((resolve, reject) => { });
promise.then((result) => { }).catch((error) => { });
Example:
const fetchData = () => {
return new Promise((resolve, reject) => { });
};
Modules
- Supports modular code organization with separate files.
- Allows exporting and importing functionalities between modules.
Syntax:
// Exporting module
export const myFunction = () => { };
// Importing module
import { myFunction } from './myModule';
Example:
// Exporting module
export const PI = 3.14159;
// Importing module
import { PI } from './constants';
Default Parameters
- Allows setting default values for function parameters.
Syntax:
function myFunction(param = defaultValue) { }
Example:
function greet(name = 'Guest') {
console.log(`Hello, ${name}!`);
}
Summary
JavaScript ES6 revolutionized the way developers write JavaScript code, offering a more modern and powerful language for building web applications.