1.Javascrips(Types of value):
Javascripts has nine types of values. This values are divided into two main categories:
Primitive values:
Undefined
Null
String
Numbers
Booleans
Symbols
BigInts
Objects and Functions:
Objects
Functions
All the other fundamentals are called objects like: array, regular expression.The value's type of javascript can be checked using typeof() operator:
console.log(typeof(2)); //"number"
2.Try-Catch:
Errors are the most common phenomenon in programming and if you are a beginner then bless you. You know what i mean. An error can occur for many reasons like we programmers made a mistakes or users put an invalid input and many more But you can handle an error with try-catch method.
When an error occurs a script dies meaning it will stop working and printing it to console. It's totally not good for users experience. That's when try-catch comes into play.
try-catch allows us to catch that error without stopping the script.
The syntax of try-catch is:
try{
//code
}
catch(err) {
//error handling
}
First the code in try block will execute and if it does not get any error then catch(err) will be ignored and if an error occurs in try block then the try execution will stop and will go to catch block. The error variables will contain an error objects with details about what happened.
3. Coding-Style:
Coding style is very important for a programmer. It must be clean and readable so other programmers can read our code. Usually we wright codes for users or a client or other developers. If our code is not readable then it will be troublesome for other developers to reuse or modify the code.
here is a detail info about how to wright code more clean:
4. Comments:
Comments are used in code to know how the code is working. It is really convenient for both users of the code and the coder himself. When a programmers comes back to his/her project after a while, comments help them why and how this code is written that way.
But its excess use can diminish code's cleanliness and readability. It is important to know when and how we use comments.
Comments has to be minimal and avoid using unnecessary comments.
5.Cross Browser Testing:
Cross browser testing is the practice of making sure that the web page or app is working across an acceptable number of web browser.
It is important that a web page or app is working in different types of browser like Chrome, Firefox, Safari and IE/Edge.
If your web app has many features like 3D animation or technologies then it might work on smart phone or high tech desktop or popular browsers but does not work on old browsers. That device or browsers has to support that tech to work. It might not even show in that browser. That's why it is really important to use cross browser testing according to your user need. What kind of users you going to target for your web app.
Usually there are four steps to follow when making a web app:
Initial planning > Development > Testing > Fixes
6.Block-Bindings(ES6):
ECMAScript 6 has introduce block level binding to make variable declaration more easy in javascript. Traditionally, the way variable declarations work has been one tricky part of programming in JavaScript. When variables is declared using var, it is treated as global variable. No matter where it is declared in a function it can be accessible from anywhere in that function. This is called Hoisting.
function(){
// x is accessible from here
if(condition){
var x = "value";
return x;
}else{
// x is accessible from here
return null;
}
// x is accessible from here
}
7.Block-Level-Declaration:
Block level declaration are those that declare variables that are not accessible from outside of a block. It has two types of syntax when declaring a block: let
and const
. Block scope are created:
1.Inside of a function
2.Inside of a block
8.Const vs Let declaration:
let declaration:
The let declaration syntax is the same as var declaration syntax. let can be used instead of var. The difference between var and let is let is accessible only in the it is declared. Unlike var it is not hoisted in the top of the functons.
const declaration:
Variables declared using const are considered constant.
const declaration are similar to let declaration. const variables are not accessible from outside of the block. but constant variables value can not be changed after assigning a value.
9.Declaring objects using const:
A const declaration of object prevents modifications of the binding but not the value of the objects.Example:
const object = {
name: 'someone'
};
//work
object.name = 'new';
//throw error
object = {
name: "new"
}
10.Functions:
Default parameters:
Functions with default parameters allows functions to use that value if that value is not pass in the parameters.Example:
function addition(a, b = 2){
return a + b;
}
addition(1, 4) // 5
addition(5) // 7
Top comments (0)