Masrukul Mridul
3 min readMay 6, 2021

--

Primitive:

In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods. There are 7 primitive data types: string, number, bigint, boolean, undefined, symbol, and null

Primitive Means that:

· The values are represented directly at the lowest level of the language implementation.

· They are immutable (i-e) they cannot be altered.

· They are always copied by values instead of reference.

· :They do not have any associated functions to perform operations on them.

Objects and Functions:

Objects and function are also value .but they both are not Primitive type.

Expressions:

An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value. The value may be a number, a string, or a logical value. Conceptually, there are two types of expressions: those that assign a value to a variable, and those that simply have a value.

try…catch:

A try…catch block is basically used to handle errors in JavaScript. We use this when you don’t want an error in your script to break our code.

try{

//…

}catch(e){

//…

}

A try statement lets you test a block of code for errors. A catch statement lets you handle that error.

This is basically how a try/catch is constructed. we put our code in the try block, and immediately if there is an error, JavaScript gives the catch statement control and it just does whatever you say. In this case, it alerts you to the error.

Coding Style:

Every language has a set of rules when it comes to syntax. Always use the latest ES version. Use Babel if old browser support is necessary.

Indentation: use spaces instead of tabs, indent using 2 spaces.

Semicolons: don’t use semicolons.

Line length: try to cut lines at 80 chars, if possible.

Inline Comments: use inline comments in your code. Use block comments only to document.

No dead code: Don’t leave old code commented, “just in case” it will be useful later. Keep only the code you need now, version control/your notes app is meant for this.

Only comment when useful: Don’t add comments that don’t help understand what the code is doing. If the code is self-explaining through the use of good variable and function naming, , don’t add a comment.

Variable declarations: Never use var. Default to const, only use let if you reassign the variable.

Functions: use arrow functions unless you have a specific reason to use regular functions, like in object methods or constructors, due to how this works. Declare them as const, and use implicit returns if possible.

Whitespace: use whitespace wisely to improve readability: put a whitespace after a keyword followed by a (; before & after a binary operation (+, -, /, *, &&..); inside the for statement, after each ; to separate each part of the statement; after each ,.

New lines: use new lines to separate blocks of code that perform logically related operations.

Quotes favor single quotes ' instead of double quotes ". Double quotes are a standard in HTML attributes, so using single quotes helps remove problems when dealing with HTML strings. Use template literals when appropriate instead of variable interpolation.

Comments:

comments can be used to explain JavaScript code, and to make it more readable. JavaScript comments can also be used to prevent execution, when testing alternative code.

Single Line Comments ,Multiline comments, Using Comments to Prevent Execution.

Cross Browser Testing:

Cross Browser testing is a type of non-functional testing that lets you check whether your website works as intended when accessed through: Different Browser-OS combinations i.e., on popular browsers like Firefox, Chrome, Edge, Safari — on any of the popular operating systems like Windows, macOS, iOS and Android.

--

--