JavaScript Fundamental Concepts Summary

Md shahinur khan
3 min readMay 6, 2021

Spread syntax (…)

The spread syntax can be used when all elements from an object or array need to be included in a list of some kind. The spread operator is a useful and quick syntax for adding items to arrays, combining arrays or objects, and spreading an array out into a function’s arguments.

function sum(x, y, z) {
return x + y + z;
}

const numbers = [1, 2, 3];

console.log(sum(…numbers));
// expected output: 6

Error handling, “try…catch”

The try..catch usually use for programming code error indicates, If you see your site not working and there are many error , you can not sure without try..catch which line of error

try {

alert(‘Start of try runs’); // (1) ←

// …no errors here

alert(‘End of try runs’); // (2) ←

} catch (err) {

alert(‘Catch is ignored, because there are no errors’); // (3)

}

Introduction to cross-browser testing

There are many kinds of browsers such as chrome, firebox, opera, internet explorer. Different browsers different kinds of behavior. When you a web developer you should think about this. Some of the devices are very old there device capability low. You should be thinking before creating a website what kind of browser and devices use it

Default parameter in Javascript

The default parameter is a way to set default values for function parameters a value is no passed in (ie. it is undefined).

In a function, Ii a parameter is not provided, then its value becomes undefined. In this case, the default value that we specify is applied by the compiler.

function test(num = 1) {

console.log(num);

}

test(); 1

JavaScript Arrow Function

It gets shorter! If the function has only one statement, and the statement returns a value, you can remove the brackets and the return keyword:

Normal function:

hello = function() {
return “Hello World!”;
}

With Arrow Function:

hello = () => {
return “Hello World!”;
}

Javascript Coding Style

As a web developer, you should maintain a coding style. When anyone sees your code let him understand. Meaningful variable, classes, components name must-have.

Example:

Always put spaces around operators ( = + — * / ), and after commas:

var x = y + z;
var values = [“Volvo”, “Saab”, “Fiat”];

Always end a simple statement with a semicolon.

var values = [“Volvo”, “Saab”, “Fiat”];

var person = {
firstName: “John”,
lastName: “Doe”,
age: 50,
eyeColor: “blue”
};

A block statement

When you create a block statement, always need curly brackets otherwise statement output returns an error.

var a= 2;
{
var a= 5;
}
console.log(a); // logs 5

Primitive Values

Undefined​ (undefined), when missing values output return undefined.

Null​ (null), used for intentionally missing values.

Booleans​ (true and false), used for logical operations.

Numbers​ (-100, 3.14, and others), used for math calculations.

Strings​ (“hello”, “abracadabra”, and others), used for text.

Symbols​ (uncommon), used to hide implementation details.

BigInts​ (uncommon and new), used for math on big numbers.

Checking a Type

when you see Javascript all values it will look the same. But when you look well there are different types of values such as “string”, “number”,“object”.

You can check “typeOf ” oparators what kind of values in the statement

console.log(typeof(‘ ’)); // “string”

console.log(typeof({})); // “object”

let num = 4,3;

console.log(typeof(num)); // “number”

Var Declarations and Hoisting

You can declare a variable global or locally. when you declare a variable globally you can access variable values anywhere in this statement.

x = 6 //global variable ;

let y = 8 // local variable

--

--