Friday, March 8, 2019

NODEJS FUNCTION AND DATA TYPES 2

Use to const 

Sametimes, You want a variable to be immutable, you can declare it with const. Just because a variable is declred with const doesn't mean it's immutable, all it means is the value can't be re-asigned.

If you want to combine two variables in an easy way we can do as in the picture. We must defining a variable single quatation mark. I tired to make single quatation. alt+g+semicolon made with key.




It is as follows to assign values ​​to the element of the const generated arrays.

Any propertiy within my object may be creating a new object. Very easy to reach at this value

In order to print the elements of the arrays on the screen, we need to put 3 points before the name of the directory into the consol log.


Or to better understand the sequence in the array printing as follows, but here we wrote the array as array.


 But if  don't you want to  in the  series write console So if you want to element in the arrays I have put the three dots at the begining of the Series name.

Assigning the values of an array to another array is as follows. I create a new array of elements in the array of values and print it to 3. makes the assignment after the index.


ARROW FUNCTİON 

This is how we can define the function.That would have taken us away from the dirty code.



Promise  : Resolved runs when everything is fine 
Reject runs when samething goes wrong.
   

All the code in the project.
          

Now let's make an example of the reject.



if we use Promise and regenerated water, we will understand better.


No comments: