JavaScript Day(2)

Urmita Chowdhury
2 min readNov 3, 2020
Photo by Irvan Smith on Unsplash

1. Types of values in JavaScript :

Primitive Values :

● Undefined​ (undefined), used for unintentionally missing values.
● Null​ (null), used for intentionally missing values.
● Booleans​ (true and false), used for logical operations.
● Numbers​ (-100, 3.14, and others), used for math calculations.
● Strings​ (“hello”, “abracadabra”, and others), used for text.
● Symbols​ (uncommon), used to hide implementation details.
● BigInts​ (uncommon and new), used for math on big numbers.

Objects and Functions

● Objects​ ({} and others), used to group related data and code.
● Functions​ (x => x * 2 and others), used to refer to code.

2. Coding style :

Our code must be clean and easy to read as possible. For good coding we should use braces carefully. Otherwise error can occur and its also not right.

3. Comments :

Comments can be single line or multiline. We should use comment when it is needed. Unnecessarily using comment is bad practice.

4. Error handling :

try…catch is used generally for error handling. It works like this:

  1. First, the code in try {…} is executed.
  2. If there were no errors, then catch(err) is ignored: the execution reaches the end of try and goes on, skipping catch.
  3. If an error occurs, then the try execution is stopped, and control flows to the beginning of catch(err). The err variable (we can use any name for it) will contain an error object with details about what happened.

5. Balancing client and server catch :

It is very important for a web developer to maintain catch between client and server.

6. var and const declaration :

var is used when in future we have to change something. But const is used if the thing will always same.

7. Spread operator :

(…) three dots allow an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected .

8. Block :

A block statement is used to group zero or more statements. The block is delimited by a pair of braces (“curly brackets”) and may optionally be labelled.

9. Arrow function :

  • Does not have its own bindings and should not be used as methods.
  • Does not have arguments
  • Not suitable for call, apply and bind methods, which generally rely on establishing a scope.

--

--

Urmita Chowdhury
0 Followers

I am a veterinary student. I am learning programming in this pandemic as I have huge time now. so this is a new experience. Love to reading story books.