You are on page 1of 9

node.

js

https://nodejs.org

install Create-React-App

npm install -g create-react-app

create-react-app demo-project

npm start

JavaScript is a popular programming language that has a wide range of


applications.

JavaScript was previously used mainly for making webpages interactive


such as form validation, animation, etc. Nowadays, JavaScript is also
used in many other areas such as server-side development, mobile app
development and so on.

console.log('hello world');
// 5 is assigned to variable x

let x = 5;

console.log(x); // 5

// vaue of variable x is changed

x = 3;
console.log(x); // 3

const x = 5;

x = 10; // Error! constant cannot be changed.


console.log(x)

JavaScript console.log()

All modern browsers have a web console for debugging.


The  console.log()  method is used to write messages to these consoles. For
example,

let sum = 44;


console.log(sum); // 44

// program to print variables values

// storing values

const greet = 'Hello';

const name = 'Jack';

console.log(greet + ' ' + name);

JavaScript Operator Types

Here is a list of different operators you will learn in this tutorial.

 Assignment Operators

 Arithmetic Operators

 Comparison Operators

 Logical Operators

 Bitwise Operators

 String Operators

 Other Operators
let x = 5;

let y = 3;

// addition

console.log('x + y = ', x + y); // 8

// subtraction

console.log('x - y = ', x - y); // 2

// multiplication

console.log('x * y = ', x * y); // 15

// division

console.log('x / y = ', x / y); // 1.6666666666666667

// remainder

console.log('x % y = ', x % y); // 2


// increment

console.log('++x = ', ++x); // x is now 6

console.log('x++ = ', x++); // prints 6 and then increased to 7

console.log('x = ', x); // 7

// decrement

console.log('--x = ', --x); // x is now 6

console.log('x-- = ', x--); // prints 6 and then decreased to 5

console.log('x = ', x); // 5

//exponentiation
console.log('x ** y =', x ** y);

JavaScript ES6 (also known as ECMAScript 2015 or ECMAScript 6) is


the newer version of JavaScript that was introduced in 2015.
ECMAScript is the standard that JavaScript programming language
uses. ECMAScript provides the specification on how JavaScript
programming language should work.

ECMAScript 6
The next big update occurred in 2015 when ECMAScript 6
(ES6) or ECMAScript 2015 (ES2015) was officially released. ES6
features modernized JavaScript.

And beyond
There have been four more updates since that time: ECMAScript
2016, 2017, 2018, and 2019. The name ES.Next is given to the
upcoming version, which is still in revision and proposal.

JavaScript let

JavaScript let is used to declare variables. Previously, variables were


declared using the var keyword.
To learn more about the difference between let and var,
visit JavaScript let vs var.
The variables declared using let are block-scoped. This means they
are only accessible within a particular block. For example,

// variable declared using let


let name = 'Sara';
{
// can be accessed only inside
let name = 'Peter';

console.log(name); // Peter
}
console.log(name); // Sara

JavaScript const

The const statement is used to declare constants in JavaScript. For


example,

// name declared with const cannot be changed


const name = 'Sara';

Once declared, you cannot change the value of a const variable.

JavaScript Arrow Function

In the ES6 version, you can use arrow functions to create function


expressions. For example,

// function expression
let x = function(x, y) {
return x * y;
}
// function expression using arrow function
let x = (x, y) => x * y;

JavaScript Classes

JavaScript class is used to create an object. Class is similar to


a constructor function. For example,

class Person {
constructor(name) {
this.name = name;
}
}

Keyword class is used to create a class. The properties are assigned in a


constructor function.

class Person {
constructor(name) {
this.name = name;
}
}

const person1 = new Person('John');

console.log(person1.name); // John

Default Parameter Values

In the ES6 version, you can pass default values in the function
parameters. For example,

function sum(x, y = 5) {

// take sum
// the value of y is 5 if not passed
console.log(x + y);
}

sum(5); // 10
sum(5, 15); // 20

You might also like