ES6 most important features as a beginner you need to know

gopal paul
4 min readMay 6, 2021

Comments

Like all programming languages, JavaScript is readable to interpret code, useful when someone tests the code and execution. JavaScript has two types of comments, single comments (starting with double forward slashes) and multiline comments (starting with forwarding asterisks and ending with asterisks forward).

Example:

let name = “Boltu” // a single line comments/* The code below will change  with name = “Nut” and last variable  is name = “Boltu” in this comment
*/ it’s a multiline comments

TypeOf() method:

The typeOf() method is used to find out the data type or name of a string or something.

Example:

let num = 20;

console.log( typeOf(num) ); // example output — ‘number’

Coding Style

To be a good developer, you need to know how to write the code as clean and easy to read. Any other developer can easily understand, read, and explain your code.

Example:

the proper way to code style

JavaScript Errors (try and catch):

Attempts statement lets you check a block of code for errors. The try statement defines a block of code to test for errors in order for you to execute.

The catch statement lets you handle the error. The catch statement defines a block of code for death if you encounter an error in the attempted block.

Example:

try {  alert(“Hello World”);} catch (err) {  alert(“Error hello world”);}

Functions

A function in JavaScript that allows you to define a block of code, give it a name and then execute it as many times as you wish. An activity can be defined using function keywords and executed using the () operator. A function may include one or more parameters.

Syntax:

function name ( parameter1, parameter2, parameter3) {

code to be executed

}

name(arguments) // calling a function

Arrow Function:

Arrow Function is a new feature of JavaScript that makes function writing easier and more readable.

syntax:

const myFunction = () => {

return “Hello World”;

}

Spread Operator:

The spread operator allows repeaters to extend where 0+ arguments are expected. It is mostly used in variable arrays where more than 1 value is expected. This allows us to get a list of parameters from the array. Like the spread operator’s syntax rest parameter but it works the complete opposite.

Syntax:

let func = […value]

Example:

let num1 = [1, 2, 3, 4]let num2 = [8, 9, 10]num = […num1, …num2] // example output [1, 2, 3, 4, 8, 9, 10]const myFunction = (x, y) => {
if(y == undefined) {
y = 2;
} return x * y;}myFunction (4); // calling a function

the syntax above is a spread operator that targets all the values ​​of a given variable. When … a function calls or something similar happens, it is called a spread operator. Spread operators can be used in many cases, such as when we want to extend a copy, Concat, with a math object.

Default Parameter values:

If a function in JavaScript is called with missing arguments (less than declared), the missing values are not determined. Sometimes this is acceptable but sometimes it is better to set a default value in the parameters.

Example:

const myFunction = (x, y) => {
if(y == undefined) {
y = 2;
}return x * y;}myFunction (4); // calling a function

Block Binding

Let and const block bindings introduce logical scoping in JavaScript. These announcements are not lifted and only remain within the block where they are announced. … The current best practice for block binding is to use const by default and change the value of a variable only when you know it.

details coming soon….

Var Declarations and Hoisting:

Variable declarations using var are treated as if they are at the top of the function (or global scope, if declared outside of a function) regardless of where the actual declaration occurs, this is called hoisting.

Example:

const function = (condition) => {

if (condition) {
var value = "blue";

// other code

return value;
} else {

// value exists here with a value of undefined

return null;
}

// value exists here with a value of undefined
}

Cross-Browser Testing

Cross-browser testing is a good way to make sure your website and web application work across an acceptable number of browsers.

Cross-browser testing involves comparing and analyzing the behavior of a website across different browser environments. This helps to ensure that the website provides the best user experience, different from the browsers used to access it.

details coming soon…

--

--