Boost Jetpack Day 2
By: Arman Hossen
Tags: Javascript Tips, JavaScript, Javascript Frameworks, Javascript Development

JavaScript Data Types

There are many data types in JavaScript which are divided into two categories ‘Primitive Types’ and ‘Reference Types’.

Primitive type are stored in a fix state if later part you overwrite it won’t do any process in previous values it will create new state and save it as new data in back hood of JavaScript

Reference types are like connected value. When you assign a value to some variable it will create some reference variable in the back hood. So if you overwrite that value actually that value will assign into that back hood reference variable. So in the code wherever that reference variable is linked the overwrote value will change.

Expressions

Expression means some code that expect some values. It is going to be some values, as an example if we say console.log(“Arman’’) then it's gonna print some value so it's and expression.

Checking Type

If you want check type of some values there is very simple way to do that . You just have to console and need to type: typeof(“Arman”) then it's going to return “string”.

Try Catch

It doesn't matter how much expert you are in JavaScript but you are going to do mistake or there will be some error maybe it can be done by you or some misunderstood input . So if you want to solve those errors you need see where and how that error is happening. So instead of dying page you can trigger those errors by try…catch method

Try Catch Syntax

First of it's going to execute the code inside try block if there is some error it's going to pass the error as exception to catch block then catch block will have a parameter by that parameter you can trigger and solve your problem.

JavaScript Coding Style

In function, you can't type spaces between function name and parentheses and between parentheses and parameter, there need to 2 space indentation ,Curly brace should be in the same line with a space, Semicolon ; in the end of every statement, else keyword should be in same line with a space. In loops spaces between operators. An empty line between logic blocks.

Instead of writing long horizontal string values it should write in template string.

Comments In JavaScript

For human-readable code we must write comments in special expressions or statements. But you can't type comments in every statement of code. You write comment in single line with // and write multiple line comment with /* */

Caching

Caching means to store the same used data in store. It means like if in website there is same req we are doing a lot of time then we can store those data in cache and instead of request same data many times it will automatically load from cache store.

Cross Browser Testing

They're a lot of browsers in the internet world almost all browsers have the same functionality. But there is a difference between every browser engine so your code can run you testing browser what if it doesn't run in other browsers, so we have to do cross browser testing to check our code runs in almost every browser

Functions with Default Parameter Values

Suppose you have written a function that takes two parameters and then when you call that function you are passing one parameter. So it's going to show error for the expected parameter of that function. In that case you have to make that function as optional you have to write that function like ‘function foo(a , b= “”){ //statement }’ then if you pass that parameter or not it really doesn't matter