Introduction of JavaScript Primitive data, Cache, Cross browsing testing and Block bindings

ROMEL
3 min readMay 6, 2021
Photo by Jexo on Unsplash

Primitive & Object type data in JavaScript:

Object and function are not primitive they are maniputable.

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

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

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

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

console.log([]); // “object”

console.log(a=>a+12); // “function”

Undefined, Null, Booleans, Numbers, Strings, Symbols, BigInts are primitive values in JavaScript. All other type are object such as array, object and function

Usually comment is done by // or /* ……….. */. The code should be self-descriptive. We should use comments in case of explaining overall architecture, high level view, important solution, function usages etc case. And we should avoid make to explain code how does it works.

Caching:

Caching is the term which is used for data availability. This method opposed to making new content each time. Clint sometime request data continuously which is kept in locally and this is called client caching. Suppose logo or brand item are cached locally & reduce the cost of client and improve overall efficiency.

Sometimes database saved some data in form of server caching which saved from generating numerous number of api calling. Actually server caching reduce the network congestion.

Hybrid caching is a done by asking whoever is responding by making a local query. First user make request which is checked in locally and then in server. If a copy is already in there then serve it or make a copy into the server. Work flow done by Initial planning then Development then Testing/discovery then Fixes/iteration.

Cross browser testing:

Cross browser testing is means that the web sites and web application we created work correctly across an acceptable number of web browsers. Browsing behave different across differently according to browsers or devices or browsing preferences. sometimes browsers make bugs, some devices may constraints that cause a web site to run slowly, display even badly. Testing is done with various browsers on our system, like Firefox, Safari, Chrome, or IE with Mac, Windows, and Linux.

Variable declarations using var are assumed as where they are at the top of the function and where this declaration is done, is called hoisting.

Block-level declarations are those which are declared variables outside of a particular block scope. It is done by Inside of a function or Inside of a code block.

Block Binding

Block Binding in Loops is done in the area of for loops, where the declared variable is used only inside this loop. Let and const are different from var is in their scope behavior. When var is used in the global scope which creates a new global variable and accessible from everywhere and we can overwrite it easily.

Best Practices for Block Bindings is to use const by default and only use let when we know a variable’s value tends to change in future code.

if no value value is passed default function parameters execute with the default values.

function add(a, b = 1) {

return a + b;

}

console.log(add (5, 2));

// output: 7

console.log(add (5));

// output: 6

An anonymous function is a function which has no name.

let anonymous = function () {

console.log(‘this is an anonymous function’);

};

anonymous();

let friend = {

first: ‘rahim’,

second: ‘karim’

};

(function () {

console.log(`${friend.first} ${friend.second}`);

})(friend);

--

--