Javascript error handling, coding style, comments.

Al-Amin Obhi
1 min readMay 6, 2021

Javascript error handling:

Try a code with a blog to check the code.
Helps the programmer to handle the catch.
Throw lets create custom error shots.
Lets finally handle errors and tri-code results.

example:
try {
adddlert(“Welcome guest!”);
}
catch(err) {
document.getElementById(“demo”).innerHTML = err.message;
}
finally {
Block of code to be executed regardless of the try / catch result
}

Technically you can throw an exception (throw an error).

The exception can be a JavaScript String, a Number, a Boolean or an Object:

Coding Style:

Coding are style guidelines for programming.
Naming and declaration rules for variables and functions.
Rules for the use of white space, indentation, and comments.
Programming practices and principles.

Coding can be documente rules for teams to follow, or just be your individual coding practice.

name variable
operators
code bindentation
functions
loops
conditionals
length
file extensions

JavaScript Comments:

JavaScript comments can be used to explain JavaScript code, and to make it more readable.

JavaScript comments can also be used to prevent execution, when testing alternative code.

(1) line comments:

var x = 5; // Declare x, give it the value of 5
var y = x + 2; // Declare y, give it the value of x + 2

(2) multi-line comments

/*
document.getElementById(“myH”).innerHTML = “My First Page”;
document.getElementById(“myP”).innerHTML = “My first paragraph.”;
*/

--

--