An Introduction with JavaScript

Figure: Javascript

What is javascript, key features of javascript:

1. Interpreted or just-in-time (almost immediately) compiled programming language[not exactly compiled language it means JS need not convert in the machine-readable language(where machine only can read 0 and 1) and then run it].

2. The first-class function can implement anything with its functions.

3. In the beginning, javaScript use only for the client-side, the browser.

4. Later, javaScript modified for server-side use, also with help of Node.js. where Node.js is not a programming language. An open-source, cross-platform.

JavaScript is a client-side(front-end) language but by using a special way we can run it in server-side(back-end), the special way is said to be as Node.js. Node.js is a system of running JS code on the V8 engine and executes JS code outside a web browser.

5. javascript is Prototype-base as there are many ways of making relations (inheritance) between classes. The way JS follows is prototype-base.

6. Multi-paradigm, paradigms like object-oriented programming, functional programming, etc can use.

7. Single-threaded, JavaScript is Single-threaded because it can not run multiple threads parallelly but due have an event loop it can work in an Asynchronous way. (the way is not parallel but Asynchronous process)

Asynchronous way means, when JS is started doing its own task at the same time it can give the task to other(not like parallel) and after the completion of the task that is done by other, it can take from it(other) and can make combination the task(other) with his task. In this, full process there will be no interruption in JS’s own work.

8. dynamic language, need not define data type when the variable is declared.

9. syntax is based on the C and Java languages.

Figure: Data types of javascript

Data types of javascript:

In JavaScript there is 5 type of data that can contain values:

  • Number
  • String
  • Boolean
  • Object
  • function

2 type of data that can not contain values:

  • null
  • undefine


  • In JavaScript number can be a decimal value or without a decimal value.
  • using javascript built-in parseInt() function we can convert a string number into an integer number as well as a float number into an integer number also.

When we applying the parseInt() function on a string if a string starting with ‘ 0 ’ then JS will consider the string as octal, on the other if the string starts with ‘ 0x ’ then JS will consider the string as hexadecimal. Also, we can change a string number into an integer using the ‘+’ operator.

  • parseparseFloat() is a function that used to accept the given string and convert the string into a floating-point number.
  • javascript use Number.isNaN() or isNaN() for detect the given number is ‘NaN’(not a number) or not, . Also, it has special value Infinity, -Infinity. which are detect by using isFinite(), also the ‘NaN’ can be detected using this function.
  • javascript provides a built-in object which provides mathematical functions and constants known as Math. It allows performing mathematical tasks on numbers.

moreMath functions are,

  • Math.Abs () — returns the absolute value of a number
  • Math.ceil() — return rounded up to its nearest integer
  • Math.floor() — return rounded down to its nearest integer
  • Math.min() — returns the number with the lowest value
  • Math.max() — returns the number with the highest value(o or more numbers given as input)
  • Math.random() — return random number in the range 0 to less than given number
  • Math.round() — return rounded to its nearest integer
  • Math.sqrt() — return the square root


  • JavaScript string is more likely than the other languages string. a string is the collection of characters that are written under a Quotation mark. example: “MD Ehsanul Haque”
  • Javascript String has many built-in Methods. some of the daily used methods are,
  1. concat() — join two or more strings and return a new string
  2. indexOf() — return index of a substring, returns -1 if not found
  3. lastIndexOf() — returns the position of the last occurrence of a specified value in a string
  4. slice() — extracts a section of a string and returns it as a new string, without modifying the original string.
  5. split() — splits a string into an array of substrings
  6. toLowerCase() — converts a string to lowercase letters
  7. toUpperCase() — converts a string to uppercase letters
  8. trim() — removes whitespace from both ends of a string
  9. trimStart() — removes whitespace from the beginning of a string
  10. trimEnd() — removes whitespace from the end of a string
  11. match() — the result of matching a string against a regular expression
  12. sub() — shows a string as subscript text
  13. sup() — shows a string as superscript text
  14. charAt() — returns the character at the specified index in a string
  15. includes() — returns true if the searchString found in the string , otherwise false
  16. startsWith() — determines whether a string starts with the characters of a specified string
  17. endsWith() — determines whether a string ends with the characters of a specified string
  18. replace() — returns a new string with some or all matches of a pattern replaced by a replacement.
  19. substr() — extracts parts of a string, beginning at the character at the specified position, and returns the specified number of characters.


To declare a new variable javascript use 3 keywords let, var, const.

  • var: function scope, can redeclare, also can reassign.
  • let : block scope, can not redeclare but can reassign.
  • const: block scope, can not redeclare, also can not reassign.


JavaScript has different types of operator,

  • Arithmetic operators : + , -, *, /, %
  • Comparison operators: <, >, =, >=, <=,
  • Logical operators: &, |, &&, ||, !, !=
  • Assignment operators: +=,-=
  • Conditional operators: ?:

we can contact two strings using the ‘ + ’ operator. when adding a string and a number using the ‘ + ’ operator, then all will convert into a string.

when we do a comparison between two variable(num, string or num, num) ‘==’ only check the value but ‘===’ check both value and the type of the value.

Control Structure

for control condition javascript use,

  • if-else
  • if-else if-else
  • while
  • do-while
  • switch-case
  • for loop
  • for of
  • for in
  • ternary operator


for creating a new object js use new object().

JSON formate,

so now if we want to access the object value. have to write like this,

we can assign a new value to the object key using dot notation,

also in,


Array can create in two way:

some methods of array,

  • array.length() — to know the total array length
  • array.forEach() — apply once on each and every element in an array
  • — creates a new array with the results of calling a function for every array element
  • array.filter() — creates a new array with all items of an array that pass the test implemented by the provided method.
  • array.reduce() — reduce the array size by applying reducer function(can be addition operation or other any kind of operation)on all the array value and return a single value
  • array.find() — used to get the value of the first element in the array that satisfies the provided condition
  • array.findIndex() — used to get the first index of the first element in the array that satisfies the provided condition
  • array.lastaIndexOf() — used to get the last index of the searching element in the array
  • array.reverse() — method reverses an array(1–2–3 will be 3–2–1)
  • array.push() — adds new elements at the end of an existing array, and returns the new length
  • array.pop() — remove elements from the end of an existing array, and returns the remove element
  • array.shift() — remove first elements from an existing array, and returns the removed element
  • array.unshift() — adds one or more elements at the beginning of an existing array, and returns the new length array.
  • array.splice() — changes the elements of an array by removing or replacing existing elements and/or adding new elements
  • array.slice() — returns the selected(from start to end) elements in an array , as a new array object
  • array.concat() — add two array and return a single array
  • array.join() — creates and returns a new string by concatenating all of the elements in an array. The elements can be separated by a specified separator. The default separator is the comma (, or -).
  • array.every() — checks whether all the elements of the array satisfy the given condition or not that is provided by a method passed to it as the argument.
  • array.sort() — sorts the elements of an array. The sort order can be either ascending (down-up) or descending(up-down) or alphabetic or numeric.


function structure,

function call and pass value as a parameter,

type of function:

  • Anonymous function: function without a function name
  • Recursive function: function with a function name and call itself until the base case less than equals 1.
  • Inner function: a function in another function.

What is SSL(secure sockets layer)

Figure: secure sockets layer(SSL)

An SSL is a security technology for your browser. It is a protocol for web servers and web browsers that makes sure that data passed between the servers and web browsers are private. This is done using an encrypted link that connects the server and browser.

I’m a junior front-end web developer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store