day 05 of 1000 days

Welcome, I wish you had a great day.

Brief:- I studied nodejs, js dsa. Practised css grid & flex. I also worked on my English skills.

detailed:-

nodejs - it's fast coz of its async nature, which is transferring big time-consuming tasks to background threads and keeping the main thread non-blocking. Non-blocking means one code doesn't block the way of code in the line next to it. If the code is taking time, it is done in the background by other threads. Nodejs is mostly used for making API. API transfer data to site, app etc. HTTP module has methods to build basic API.

http.createServer(function).listen(portNumber)

The function takes two arguments, request and response. There are many ways to send a response, I learned the writeHead method.

(req,resp)=>{    //req=request, resp=response
 resp.writeHead(200, { 'Content-Type': 'text/plain' });
 resp.write('html or data in string format'); 
 resp.end()
}

200=status code, there are many codes for various responses. 404 is for error and 200 means ok. Next, we send the type we are sending in the head. In the write method, we send data in string format. Mostly this data is in the array, whose elements are objects. This object contains user data or other data. We will have to convert it using JSON.stringify. The end method indicated the end of the response. I will write about how the web works tomorrow as I am confused about one of the topics. There is a 3rd party package 'nodemon' it's similar to a live server extension. It basically used to reload the files and keep the server going. Though node has a built-in feature --watch but it's in the experimental stage. There are many other good 3rd party modules. My only confusion is regarding commonjs and es6 modules.

js(DSA): I studied BigO. It gives a general idea about how the algorithm will perform in a worst-case scenario when input increases too much. It's a way of generalising algo and comparing them. It's of two types 1) time complexity 2) space complexity. Time complexity is measured by counting number of operations. Space complexity we count space that algo will take. I will share more about it later. I also learned some patterns (honestly I got confused over them)

Tomorrow I will again start making projects, probably small ones as they do give some confidence.