Boost Your Javascript Knowledge-Part2

Md Abdullah All Naim
3 min readNov 3, 2020

--

There are two types of Javascript data.

  1. Primitive data type
  2. Reference data type

Primitive Data Type:

Primitive data types deal with values it has no concern about variable addresses. they are number, string, boolean.

let's see an example:

let a = 5 — — an address will be created to store a

let b= a — — an address will be created to store b, but the address of a will remain the same.

a = 20 — — the value of a has-been changed

console.log(b) — — — 5

console.log(a) — — — 20

Reference Data Type:

The reference data type deals with the addresses of the variables.

they are array and object.

Let’s see an example :

let arr = [ 1, 2, 3, 4]

let newArr = arr — — here the addresses for newArr and arr are the same.arr

arr[0] = 5 ;

console.log(arr) — — [ 5, 2, 3, 4]

console.log(newArr) — — [ 5, 2, 3, 4]

typeOf():

This method is used for knowing the data types. I am sharing some examples so that you can understand the data type of any data.

Error Handling:

try{}:

any coding error inside try does not bother any code.

catch{}:

the catch will capture the error inside the try block and then it will store that error and print it as a normal text.

let’s see an example:

try {

test();

}catch(err){

console.log(err) — — ReferenceError : test is not defined

}

here, test function is not defined so there will be an error. catch will capture that error and will print as a normal text in the console.

finally{}:

whether there will be an error or not inside try-catch, the code inside finally will run successfully

try {

test();

}catch(err){

console.log(err) — — ReferenceError : test is not defined

}finally {

alert(“Inside finally’’)

}

Javascript comments:

comments are used to give info about the code and it won’t run as a code. It will remain in the code editor and only the developer will see that comments.

It is a good practice of writing comments.

there are two types of comments.

  1. single-line comment:

a single-line comment is written after this //

//……….

2. multiline comment:

/* */ multiline comments are written inside this.

/*……..*/

What Is Cross Browing?:

Cross Browing:

It’s a test of making sure that your website is working across an acceptable number of web browsers. as a developer, it is your responsibility to test it.

Besides, as a developer, you should imagine yourself as a user to feel the test of using your website.

Coding Style:

coding style:

It is really a fact that how you solve any problem by coding. It is necessary to clean your code and try to make your code better readable. this is an art that makes you a better programmer. If your code is clean and easy to read then you have gained the art of programming skill.

I have some suggestions that will make your code more readable. I have gained those techniques on the internet.

  1. always give spaces between parameters
  2. to give spaces between operators.
  3. indentation is required for better code readability.
  4. curly braces on the same line should be neglected
  5. Do not repeat your code
  6. an empty line should be avoided.

Introduction to asynchronous programming:

This is a data transmission method where data is sent without loading and you can do any task without getting bored and it is used when the server takes time to finish its task.

characteristics of async :

  1. half-duplex type transmission
  2. start and stop bits are added with data for security
  3. data is sent in the form of byte or character
  4. data transmission is slow
  5. no loading no need to wait

--

--

No responses yet