Boost Your Javascript Fundamental Concept

Minhaj Sadik
4 min readMay 7, 2021

try … catch

try and catch is a saved your crushed program, while you use this try and catch, you’re sure your program isn’t crushed, but while it was crushed don’t worry, it’s working with your crushing code.

for example, there’s a syntax construct try…catch that allows us to “catch” errors so the script can, instead of dying, do something more reasonable.

Comments

Two different types of comment in JavaScript. Single line comment and multi-line comment, you can write anything commenting line but it was some hints of your code.

Single line comment example : // This Is Single Line Comment, write your code related anything.

Multi-line comment example : /** This is multi-line comment example, if you type anything here don't worry, it's can't show*/

Cross Browser Testing

Browser Testing Is Very Important, Cause today have a many browsers support, and every browser is a different type of working and different type engine. every developer when you’re released her application should check your applications.

You need to think about this :

Different browsers are other than the one or two that you use regularly on your devices, including slightly older browsers that some people might still be using, which don’t support all the latest, shiniest CSS and JavaScript features.

Different devices with different capabilities, from the latest greatest tablets and smartphones, through smart TVs, right down to cheap tablets and even older feature phones that may run browsers with limited capabilities.

People with disabilities, who use the Web with the aid of assistive technologies like screen readers, or don’t use a mouse (some people use only the keyboard).

Remember that you are not your users — just because your site works on your MacBook Pro or high-end Galaxy Nexus, doesn’t mean it will work for all your users — there’s a whole lot of testing to be done!

Arrow function expressions

An arrow function expression is a compact alternative to a traditional Function-Expression, but is limited and can’t be used in all situations.

Arrow Function Code Example

description: Arrow Function when you write a thousand line you’ll try the arrow function, cause the arrow function is simple rather than a normal function and easier to write.

JavaScript Functions with Default Parameter Value

In JavaScript, function parameters default to undefined. However, it’s often useful to set a different default value. This is where default parameters can help. In the past, the general strategy for setting defaults was to test parameter values in the function body and assign a value if they are undefined

function multiply(a, b = 1) {

return a * b;

}

here b= 1 was the default parameter for this function.

JavaScript anonymous functions

An anonymous function is a function without a name. An anonymous function is often not accessible after its initial creation.

The following shows an anonymous function that displays a message:

let show = function () {

console.log(‘Anonymous function’);

};

show();

In this example, the anonymous function has no name between the function keyword and parentheses ().

Because we need to call the anonymous function later, we assign the function to the show variable.

Var Declaration

var declarations, wherever they occur, are processed before any code is executed. This is called hoisting and is discussed further below.

The scope of a variable declared with var is its current execution context and closures thereof, which is either the enclosing function and functions declared within it or, for variables declared outside any function, global. Duplicate variable declarations using var will not trigger an error, even in strict mode, and the variable will not lose its value unless another assignment is performed.

Hoisting

One of the advantages of JavaScript putting function declarations into memory before it executes any code segment is that it allows you to use a function before you declare it in your code. For example:

function catName(name) {
console.log("My cat's name is " + name);
}

catName("Tiger");

/*
The result of the code above is: "My cat's name is Tiger"
*/

The above code snippet is how you would expect to write the code for it to work. Now, let's see what happens when we call the function before we write it:

catName("Chloe");

function catName(name) {
console.log("My cat's name is " + name);
}
/*
The result of the code above is: "My cat's name is Chloe"
*/

Block-level declarations.

Block-level declarations are the ones that declare variables that are far outside of the given block scope. Block scopes, also known as lexical scopes, are created either inside of a function or inside of a block.

var x = 1;
let y = 10;

if (true) {
var x = 20;
let y = 2;
}

console.log(x);
// expected output: 20

console.log(y);
// expected output: 10

Thanks

--

--