JavaScript

Moyuri Akther
2 min readMay 6, 2021

Primitive data type: primitive data don’t have any data or object. primitive data type: symbol, string, boolean, number, bigInt, undefine, and null. all type of primitive values is common.

  1. Boolean: Boolean only have two values true and false.Ex: let a = 5; let b = 6; let c = 5; (a == b) //false ; (a == c) //true.
  2. Number: JavaScript have only one type of number with or without decimal Ex: let x = 10.5; let x = 10
  3. Undefine: a variable without value is called undefine in javascript. Ex: let a //undefine
  4. Null: data type of null is an object in javascript.

Try And Catch: The try catch block is basically used to handle javascript error.the try statement let you text block of code for errors and the catch statement let you handle errors.

Ex: try {
//your code
}
catch(err) {
//handle errors
}

This is basically how a try/catch is constructed. You put your code in the try catch, and immediately if there is an error, JavaScript gives the catch statement control and it just does whatever you say. In this case, it alerts you to the error.

Coding Style: Code should be clean.readable and understandable.variable name function name should be meaning full. bracket start, bracket end, space, noSpace, enter this thinks are important for coding. coding is a art for programmer. Example:

if (time < 20) { //good coding style
greeting = “Good day”;
} else {
greeting = “Good evening”;
}

if (time < 20){ //bad coding style
greeting = “Good day”;}else{
greeting = “Good evening”;}

Comments: comments can be single line or multiline.Single line comments start with // double line comments start with */ end with /*.Example:

/*
The code below will change
the heading with id = “heading”
and the paragraph with id = “paragraph”
in my web page:
*/
document.getElementById(“heading”).innerHTML = “My First Page”; //single line comment
document.getElementById(“paragraph”).innerHTML = “My first paragraph.”;

Caching: Caching is the process of storing copies of files in a cache, or temporary storage location, so that they can be accessed more quickly. Technically, a cache is any temporary storage location for copies of files or data, but the term is often used in reference to Internet technologies.

caching

--

--