JavaScript Data Types, and Error Handling with a little bit of ES6

Number — 1,2,3,4

Strings — “hello”, “world”

Boolean — true, false

Undefined — undefined

null — null

Object — {index: value}, [value1, value2, value3]

Function — functionName()

typeof(1); // numbertypeof(‘1’); // stringtypeof(true); // booleantypeof({index: value}); // object
try {    // your code…} catch (error) {    // error handling}
const value = 1;
console.log(value); // 1 console.log(“try executed”); // try executed} catch(error){console.log(error);}
const value = 1;
console.log(x); console.log(“try executed”);} catch(error){ console.log(error.message); // x is not defined}
const value = 1;
If (value > 0){ throw new SyntaxError( ‘your value is greater than 0’ ); }} catch(error){ console.log(error.message); // your value is greater than 0}
if (true) { const variable = 1; }
const add = (x, y) => x + y ;const add = () => 1+1 // 2
for ( let i = 0; i < 5; i++) {codes}
if (condition){   \\  your codes here}

Line length should be around 80 to 120 characters.

Horizontal indent should be 2 or 4 spaces.

An extra line break can specify a vertical block.

Put a semicolon after every line or statement.

You can place functions on top of code or bottom of code. Additionally, you may place it while calling the function.

To make your code readable with one click, you can use the “Prettier” or “ESLint” extension on VSCode.

Add comment is an important thing. Your commenting style will show you how you can describe a code to outsiders.

The explanation will be in short and minimal

Comment on the original architecture of your code, usage of functions, and important solutions.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store