Learn 10 Basic JavaScript Fundamental Concepts as a Junior Developer.

Objects and Functions

Objects and functions are special because ​I can manipulate them from my
code​. For example, I can connect them to other values.

“try…catch” syntax

No matter how great we are at programming, sometimes our scripts have errors. They may occur because of our mistakes, unexpected user input, an erroneous server response, and for a thousand other reasons.

  1. If there were no errors, then catch (err)is ignored: the execution reaches the end of try and goes on, skipping catch.
  2. If an error occurs, then the try execution is stopped, and control flows to the beginning of catch (err). The err variable (we can use any name for it) will contain an error object with details about what happened.

Do You know try…catch only works for runtime errors?

A program during execution is called runtime errors. The main purpose of try…catch to work, the code must be runnable.

try {
{{{{{
} catch (err) {
alert(“Error has occured”);
}

try…catch works synchronously

If a programmer used setTimeOut method, then try catch won’t catch it.

try {
setTimeout(function() {
myVariable
}, 1100);
} catch (err) {
alert( “didn't work” );
}
setTimeout(function() {
try {
myVariable;
} catch {
alert( “Error” );
}
}, 1000);

Error Object

When an error occurs, JavaScript generates an object that are passed as an argument to catch.

try {
// code
} catch (err) { //error object
// code
}

try…catch”

Let’s go to a real life example, JSON. We mainly used to get the decoded data by using JSON parsing. A simple example of JSON is:

json = ‘{“name”:”Mahmudur”, “age”: 23, “occupation”: “Web Developer”}’;
let json = “{ wrong json }”;
try {
let user = JSON.parse(json);
alert( user.age ); // doesn’t work
} catch (err) {
alert( err.name );
alert( err.message );
}

Own errors

Sometimes, you see that json is syntactically correct but you don’t have a occupation property. See this.

let json = ‘{ “age”: 23 }’;try {
let user = JSON.parse(json); // ← no errors
alert( user.occupation );
} catch (err) {
alert( “no execution” );
}

instanceof operator

We can check the type of error by using instanceof operator.

try {
varA = { /*…*/ };
} catch (err) {
if (err instanceof ReferenceError) {
alert(‘Error has occured’);
}
}

try…catch…finally

finally statement used to execute the code after try and catch. The code is:

try {
// code
} catch (err) {
// code
} finally {
// code
}

Single Line Comments

Single line comments start with //.

Example

// Change heading:
document.getElementById(“myH”).innerHTML = “My First Page”;

Multi-line Comments

Multi-line comments start with /* and end with */.

Example

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

Introduction to cross browser testing

As a web developer, it is your responsibility to make sure that not only do your projects work, but they work for all your users, no matter what browser, device, or additional assistive tools they are using.

Client And Server Caching in Web Application Development

Client Caching

My name is Nadim Mahmud. I am a software developer with extensive knowledge in programming, web development, mobile development, and database design.