10 Fundamental thing you want to know about Javascript

Raj dev Ullash
2 min readMay 6, 2021

Primitive: Primitive is data type or value, not object. There are 7 types of primitive data: String, Number, Bigint, Boolean, Undefined, Symbol, and Null. Example: console.log(5); //Number
console.log(“hello raj”); //string
console.log(undefined); //undefined

Expression: expression is a snippet of code that evaluates a value.

Example: 4+ 4// 8

'Hello' + ' ' + 'World' // 'Hello World'

Checking a Type: when we want to check the data type, we can use typeof operator such as ‘string’ ‘object’ & ‘number.’

Example: console.log(5); //Number
console.log(“hello raj”); //string

Errors: When we write a code, sometimes we can face errors. It can be made by the programmer, errors due to wrong input, and other unforeseeable things.

Try and Catch: The try statement allows you to define a block of code to be tested for errors while it is being executed.
The catch statement allows you to define a block of code to be executed if an error occurs in the try block.

Example: try {

Block of code to try

}

catch(err) {

Block of code to handle errors

}

Error Object: JavaScript interpreters throw an Error object when a script error (exception) occurs.

Example: try { // … }

catch (err) { // ← the “error object”, could use another word instead of err // …

Coding Style: you have to write code clean, correct & human readable.

Line length: Try to keep the length of lines less than 80 characters. This would make the code easier to read. The best practice is to move to the following sequence using break if JavaScript statements aren’t fitting in a single line.

Comments: JavaScript comments can be used to explain JavaScript code and to make it more readable.

Example: Single line comments start with //,

Multi-line comments start with /* and end with */.

Function: A JavaScript function is a block of code designed to perform a particular task.

Example: function myFunction(p1, p2) {
return p1 * p2; // The function returns the product of p1 and p2
}

--

--

Raj dev Ullash

Hello, I am Raj dev Ullash. I am a front-end developer. I primarily focus on writing clean, elegant, and efficient code.