Various topic
4 min readNov 3, 2020
In this article, you will find various topics. I talked about coding style, comments, Javascript types, JavaScript arrow function, and spread operator. JavaScript try and catch, Cross browser testing, caching, client caching, server caching
Coding Style
- It is very important when you learn a new language how neat and clean your code is. You need to ask yourself can others read your code easily. Because there will be multiple other coders trying to understand your code. If you add comments in your coding it should make sense, means including you others can thoroughly understand. Don’t make your coding complicated so that even you will get confused. This will be the best practice in my opinion!
Coding comments
- When you will code it is obvious that you comment out to understand the connection later on. This way it makes a coder life much easier. But commenting doesn’t mean you are explaining each and every line of your code. In my understanding, it is more like why I created this component or function comment on top of your code so that you can recall your work and others can easily understand.
- Javascript arrow function is a very clean and concise syntax, it is an ES6 model. If there are multiple parentheses then we use like this, const arrow = (a , b) => a + b; If there is single parentheses then we use like this const arrow = first => first[0];
- Javascript spread operator is also called three dots which looks like this … you can use spread operator in a math function, adding an item, adding to state in react, combining objects, copying an array. For example, const fruits = [ ‘apple’, ‘orange’, ‘banana’, ‘peach’, ‘cherry’]
Const moreFruits = […fruits];
Using the spread operator the list of fruits spread into three dots. This is a convenient way of copying an array.
JavaScript types
- There are six types of primitives — string, boolean, null, undefined, number, and symbol. It will be easier to understand once you start coding. Lets elaborate more, string is an array of characters which consists of numbers and letters, null is no value, boolean is true or false, undefined is a declared variable but hasn’t been given a value, symbol is a unique value that’s not equal to any other value, number is integers, floats, etc.
JavaScript try and catch method
- First of all, there is the try….catch method which is very important to understand. If there is an error then the code will stop running. If the code has no error then it will run smoothly. Check out the diagram so it will be easy to understand. Basically, catch gets all the error from try, because all the code is written in try.
- Cross-browser testing — let’s get familiar with this terminology. For a web developer, it is very important that his/her UI is easy to access to all users. Every user has a different personality, not everyone uses the same device or same browser. So cross browsing testing is after you build a website you check in different browsers and different devices. Make the website responsive so that it becomes user friendly. Moreover, keep in mind for the disabled and old people who can’t maneuver your website because of high technology. Also, once you finish your website do load testing, stress testing, bug testing, etc, before launching to the public.
- Let’s dive into what is catching. The concept of catching is when a user is asking for data on how efficiently it is available to the user. In simple word cache is a temporary storage area, this means when you visit one website the information is stored so that when you visit next time the browser can retrieve the data or information from cache rather than from a server. This saves time and network traffic.
- Client-side caching is a technique that helps the end-user with high performance service and clients save the data cost. When users use the same data multiple times the data is stored in local storage for a specific period of time. In this way, if the user looks for the same data it’s faster to send the request. On the other hand, if a user searches for something new, it sends information to the server to get the request. This is very costly for the client. Monotonously, if a user searches for the same data it doesn’t make sense to keep the server busy.
- Server caching is when a user searches for information that it brings out from the server. The server site data is stored permanently unless changed. In short, the client makes a request to the API, the server receives the request than if the data is not available in the local storage than the information sent from the server.