Brief Discussion about JavaScript

Md Mazharul Islam
3 min readMay 5, 2021

Brief Discussion about JavaScript

a) JavaScript:

JavaScript is a scripting or programming language. It is used to dynamic a website. It is compared with cake layers which first and second layers are HTML, CSS and the third layer is JavaScript. It is most important for a website to implement many functions. It is used to implement many features of web pages also. Like scrolling, animation, interactive items etc.

b) Variables:

In JavaScript variables are declared using one of three keywords. These are : let, const or var;

Let:

It allows you to declare block-level variable. It is available from the block where it is enclosed in.

Conts:

It allows you to declare variable whose values are never intended to change. It is available from the block where it is declared in.

Var:

It is the most common declarative keyword in JavaScript. It does not have restriction which is other two keywords have. That’s why it is mostly used to declare variable in JavaScript. A variable declared with var is available from the function where it is declared in.

c) Operators:

JavaScript has many types of operators. Some mostly used operators are:

· Assignment (=)

· Addition (+)

· Subtraction (-)

· Multiplication (*)

· Division (/)

· Reminder (%)

JavaScript has both binary and unary operators and one special turnery operator also. A binary operator requires two operand or values, one before the operator and other after the operator. Like example:

5 + 6 or x * y;

d) Functions:

Functions are the core component in understanding JavaScript. The simple function is:

function add (a, b){

var total = a + b;

return total;

}

This is a basic function. JavaScript function can take 0 or more parameters. This body can take many statements as you like. Here return statement is used to return value at any time. If it is not used JavaScript return undefined.

e) Number:

In JavaScript Number is used to represent and manipulate the numbers like 12 or 0.25. Using the Number() function values of other types can be converted to number. When it is used as a function, to convert other value or a string to the Number type, if the value can’t be converted it returns NaN. Like example;

Number(‘123’) // 123;

Number(‘abc’) // NaN.

f) Math:

Math is a built in object that has properties and methods for mathematical functions. It works with the number type. It is not a constructor. All properties and methods of Math are static. You refer to the constant pi as Math.PI and you call the sine function as Math.sin(x).

Here is an example of converting degrees and radians using Math;

function degToRad(degrees) {

return degrees * (Math.PI / 180);

};

function radToDeg(rad) {

return rad / (Math.PI / 180);

};

g) Math.round:

The Math.round function is used to round the value of a number to the nearest integer. If the value of a number is grater then 0.5, the argument is rounded to the integer next higher value. If it is less then 0.5, the argument is rounded to the lower absolute value.

Example:

Math.round(20.22) // result 20;

Math.round(20.51) // result 21;

h) Math.floor:

i) Math.max:

How to secure your website

SSL:

It stands for secure sockets layer. It called SSL Certificate. Which is used on websites for more security. It secures website data. It is helpful also for SEO. When you browse the website you will see that the link will be started with “http:// or https://. If you see that website will be started with https:// you can understand, in that site used SSL certificate. You can browse this site without any hesitation. You can depend on this site about your data or privacy policy.

--

--