Some Important Topics in JavaScript

Primitive values are numbers and strings, among other things. All primitive values have something in common. There are 7 primitive data types: Undefined, Null, Boolean, Number, String, Symbol, and BigInts.

● Undefined​ (undefined), used for unintentionally missing values.
● Null​ (null), used for intentionally missing values.
● Booleans​ (true and false), used for logical operations.
● Numbers​ (-100, 3.14, and others), used for math calculations.
● Strings​ (“hello”, “abracadabra”, and others), used for text.
● Symbols​ (uncommon), used to hide implementation details.
● BigInts​ (uncommon and new), used for math on big numbers.

Most of the time, a primitive value is represented directly at the lowest level of the language implementation.

try….catch

The try...catch construct has two main blocks: try, and then catch:

First, the code in try {...} is executed.

If there were no errors, then catch (err) is ignored: the execution reaches the end of try and goes on, skipping catch.

If an error occurs, then the try execution is stopped, and control flows to the beginning of catch (err). The err variable (we can use any name for it) will contain an error object with details about what happened.

try...catch only works for runtime errors

Coding Style

It is the art of programming. Our code must be as clean and easy to read as possible.

What rules we follow to write a code

  1. They thought curly braces are not needed ❎
  2. Split to a separate line without braces. ❎
  3. One line without braces.❎
  4. The best variant is: ✅

5. No one likes to read a long horizontal line of code. It’s best practice to split them.✅

6. A horizontal indentation is made using either 2 or 4 spaces or the horizontal tab symbol.✅

7. Vertical indents: empty lines for splitting code into logical blocks. ✅

8. A semicolon should be present after each statement.✅

Comments

Comments are two types: Single Line and Multiple Line.

Single Line comments starts with ➨ //

Multiple Line comments starts with ➨ /* …. */

An important sign of a good developer is comments. Good comments allow us to maintain the code well.

Client Caching

Client caches help limit the data cost incurred by the user by keeping commonly referenced data locally. The client often requests data that may not be large but is indeed continuously needed. The benefit here is that the network for the client does not face heavy traffic demands without cause, as a great many content requests can be kept local. Additionally, this frees up time on the server side, which no longer has to field repeat queries that have already been answered.

Server Caching

Server caching helps limit the cost incurred by the server and its underlying systems. Many requests made by clients can either be responded to using the same data, or responded to using parts of the same requests made by others. By synchronizing the current database nightly after the synchronization with the user changes, the server can provide a “fallback” for when new clients are created or old backups are corrupted. This enables a single database query to be performed on the server side each day barring emergency queries, thereby saving significant processing power and network transfer.

Cross Browser

Cross browser testing is the practice of making sure that the web sites and web apps work across an acceptable number of web browsers. As a web developer its our responsibility to make sure that our projects run perfectly in all devices.

  • Different Browser-OS combinations i.e., on popular browsers like Firefox, Chrome, Edge, Safari — on any of the popular operating systems like Windows, macOS, iOS and Android.
  • Different devices i.e., users can view and interact with your website on popular devices — smartphones, tablets, desktops and laptops etc.
  • Assistive Tools i.e., the website is compatible with assistive technologies like screen readers for individuals who are differently abled.

Why cross browser test is important

Nowadays, cross-browser testing plays a more important role than before, as earlier this process was used only for the most difficult projects and gained more popularity as time went by. As more and more websites appear day by day, the only way to stand out of the pack is to create a truly professional website. Let’s imagine a situation where your next client is using Internet Explorer? What should you do? Refuse this offer and lose the client because the site is not displayed in it? And with the appearance of responsive web design, maintaining cross-browser compatibility has become really difficult.

Arrow Function

Arrow functions were introduced in ES6. Arrow functions allow us to write shorter function syntax:

Before Arrow function
With arrow function