1.Javascript:
javascript is a dynamic language that developers can use to make an interactive website. It is first invented by Brendan Eich in 1995 and It was released in 1996.
Unlike other programming languages javascript is designed to run as a scripting language in a host environment. That is why it is really popular language among developers.
javascript is a versatile language that has built in objects, types, array, methods, operators and function. its syntax is similar to java and C languages.
2.Variables:
Javascript variables can have values with different data-types. like: string, number, boolean, array and objects.
javascript uses one of three keywords when declaring a variable. This are: let, const and var.
let:
let is a block level variable that is available from the block it is declared.
Example:
function example(){
//it's not accessible from here
for(let i = 0, i < 5, i++){
//accessible
}
//it's not accessible from here
}
const:
const is a static variable which value can't be changed. it is available from the block it is declared.
Example:
const a = 2; //value is set
a = 50; // will throw an error
var:
var is the most common keyword in javascript. 'var' declared variables can be accessible from anywhere in the function. So it can cause problem in future. It is preferable to use let or const rather than var. Example:
function example(){
//var is visible in here
for(var i = 0, i <5, i++){
//accessible from here
}
// also accessible from here
}
3.Operators:
In javascript there are operators called numeric operator like +
,-
,*
,/
,%
. There are also assignment operator =
and comparison operators <
, >
, <=
, >=
. Example:
let a = 1 + 2;
let b = 5 - 1;
let c = 2 * 1;
let d = 9 / 3;
4.Conditionals:
Conditionals are structures that are made to look whether a statement is true or false. If the statement is true then the function is executed. If and else are two conditionals in javascript.
5.Objects:
Objects are collection of name and value pairs. It's similar to dictionary in python. In js, objects are declared in two ways:
var object = new Object();
var object = {};
The object's value can be accessible by calling its name attribute:
let object = {name:'s', age: 24};
console.log(object.name);
Once created, the exist properties of an object can be changed in this way:
onject.name = 'x'
6.Arrays:
Arrays are another type of object in javascript. Arrays are created in this manner:
let x = new Array();
x[0] = 1;
x[1] = 2;
x[2] = 3;
If an array is empty, the value of an array will be undefined. arrays are iterable using loops.
7.Functions:
Functions are most used and useful element in a language.
It reduces the repetition of the same code. Functions have to be defined before it is called and it can called as many times as you want. Example of a function:
function example(x,y){
return x + y;
}
In javascript, functions can take 0 to more arguments. Functions can be declared in another function definition.
8.Strings:
Strings are types that holds data in a text form. There are may built in methods in js that are used in string to manipulate its value.
Some of them are described bellow:
endsWith():
endsWith()
method determines whether a string ends with the characters of a specified string:
const str = 'value';
console.log(str.endsWith('e')); // returning the value true
includes():
The includes()
method determines whether a string is present in another string:
const str = 'hello world';
const word = 'hello';
console.log(str.includes(word))// return true
indexOf():
The indexOf()
method returns the index value of a string from a specified string. It returns the first index it can find of that calling string object. If it does not find the string it will return -1
.
slice():
The slice()
method returns a extracted string of a specified string without modifying the original string.
Example:
const str = 'The cat';
console.log(str.slice(3))// expected output cat
9.Number:
javascript has two built in numeric types: Number and BigInt.
There are many built in methods that are present in numbers.
10.SSL:
When we go to a website, we see two types of URL http://
and https://
. It is necessary to have that extra s
to secure a website. When we fill a form giving personal information like email or bills. It is important to know that our information is secured and does not go to any other person. That extra s
give us that security that we want. It's called SSL which stands for Secure Sockets Layer
.
Top comments (0)