Some Javascript topic You should know

Primitive Data type

Javascript has two data types. One is a primitive value and other is Reference value.

List of Premitive value is string,number,boolean,null,undefined,symble(es6).On the other hand List of Reference value is object,array,function,date.

Primitive value is immutable.when primitive value create it does not change. That means if you change the primitive value you can not do it.

example :

Let's look at another example

Take a good look at the example. There is no change of a value.It creates different, a & b value same as each other.It's just creating another store when set var b = a. This is called primitive data value. But you can change data value when-

this method call Non-primitive value.

Hopefully, you understand. Thank you.

typeof ()

typeof() is a function where put the data value it will be found what kind of data. What is the value of data type string, array, number boolean or undefined, you can easily get it. typeof() method.
example:

try-catch error handling

Suppose we have written twenty lines of codes. If Somehow code error in the fourth line, those line program will be stopped and the code will not work in the fourth to twenty lines. If we use error handling method the program easily runs if code error in any line.So try-catch has come to solve fro this problem.

example:

See the example above. The first two values code ok so the code will be run without problem . When it will be come on three line it will be failed because x value is not set. Now

we can see the example inside the try where first ,second code working ok when will come third line then catch function catch the error and it show the output.Code working fine.

Code Style

As a programmer, we should follow clean code style method. If you want to a good programmer you should practice how to code clean.code clean means your code looks like clean and follows the coding rules.Code will be human readable.

suppose your write a function and it has more parameter.You should not declare one line you should one by one line: Example

some example of coding style

you can see other example: https://javascript.info/coding-style

Comments

We don't just read our code, another developer also can read. So if we code with comments it is easy to read, It will be easier for another developer. And how this code works ,it will be easy to understand when another developer sees it.But we should avoid bad comment.

Bad comment example

Good comment example

Arrow Function

Javascript has many functions. One method is a normal function and another is the Arrow function. I choice normal function to compare because it is easy to understand how to work the arrow function. Ok, let's follow example

look at the example above. Just arrow junction parameter the qual sign sits next to it . other is look like same .The point Look at is on the right side arrow sign of the parameter, that's why it is called arrow function.

Curly Brackets{}

Javascript projects curly brackets are written in the Egyptian style. If someone reads programs written in JavaScript, It should be able to read.If we use curly bracket in code our code will be clean and readable.Curly brackets are use function,conditional,objects ,destructive etc.Curly braces { } are special syntax in JSX. It is used to evaluate a JavaScript expression during compilation.

Object

Javascript object is a another data structure where canstore multiple data. It is a reference data type.It is data collection method.Here the data is arranged in a different ways. Suppose you have student data. Here the student is an object.we can store student data name,age,roll,address etc.example:

we can detect every student data with object mathod.

Function

The functionto to learn any programming language is one of its main thing . All languages have function.The function is nothing more than naming codeblock.If you call that name anywhere in the code later,the code block will be executed.But sometimes it is work different way on javascript.