10 JavaScript Interesting Topics That Every Programmer Should Know — part 2

Josesaurav
4 min readMay 6, 2021

Hello everyone, Today I am going to talk about some interesting topics of javascript. So, let’s get started.

Primitive values and non-primitive values

There are many data types in javascript. Some of them give output only things such as numbers, strings, boolean, etc. and we can’t do anything further with them after execution. These are called Primitive values. On the other hand, some data types give out such as object, function, etc. and we can do anything with the result after execution because they are also called methods. And these are called non-primitive values.

Expression

First of all, we need to know what is an Expression? Expression is a process by which we can express our feelings to others. For example: What is your name? And Anyone can answer this question. So it can be called an expression. But in javascript expression is does something else. For example, if we ask javascript ‘50 + 50 = ?’ and he will answer 100. This is the expression of javascript But if you ask javascript “do you love me?”❤️ he will be fooled. So, this is not an expression in javascript. I think you got the question.

typeof() Function

There are many data types in javascript. So, it is confusing to everyone what is the type of a data? To get rid of this confusion javascript has a built-in function which is called typeof() function. By using this we can easily know what is the type of a data? Okay, I am giving you an example below:

console.log(typeof(15)); // "number"
console.log(typeof("Hello javascript")); // "string"
console.log(typeof(undefined)); // "undefined"

How does “try-catch” syntax works

To err is human. So, when we write codes sometimes unknowingly we make mistakes. So, to get rid of this problem we can use “try-catch” syntax to catch our coding mistakes.

try {
// code...
} catch (err) {
// error handling
}

In the above example, there are two blocks. They are “try” blocks and “catch” blocks. First, the code is executed in the “try” blocks if there are any syntactical or other mistakes in the code the execution jumps to the “catch” blocks and shows the error. If there are not any mistakes in the “try” blocks then the execution reaches the end of the “try” blocks and ignores the “catch” block. Does it make sense?

Coding style

There are no strict rules in coding style. But you can not be liberal in coding style. To practice a standard and human-readable coding style you have to follow some specific rules to understand your code better for others. Imagine, you are working for a tech company and you are doing a project with your team. Each member of your team is coding with their choice. So, if you want to check other code or want to add more extra features to the project it can be difficult to understand the code. On the other hand, if all the team member maintains a specific rule of coding it will be easy to understand one code to another.

Good comments and bad comments

Comments are part of a coding style. Comments are important to understand complex algorithms. But someone comments inside a function that “This code will do this….. and this….. and this…. ” this is not the right way to comment and this is called bad comments.

To comment the right way, we can comment above of a function in short the bird’s eye view of the code, this is called describe the code architecture. The second things use a function to describe the code and avoid comments, and this method is called self-descriptive. And these are the example of good comments.

Cross browser testing

Cross-browser testing is an important part of web development. As a developer, you have to keep in mind that the application you create will work rightly in an acceptable number of browsers. Because there are some new features in every language which are not working properly in every browser. Imagine, you are developing an application in chrome and you test it properly in that browser but a user using an old browser that is not capable to support new features of programming language. So, the user can’t use the application properly. Which is bad for your application growing. So, to avoid this kind of situation you have to test your application in a good number of browsers with some process. And all the process is called cross-browser testing. But keep in mind, if you want to test your application in all the browsers in the world, you will become mad.

Arrow function =>

Arrow function is introduced in ECMAScript 6(es6) which is the updated version of javascript language. The arrow function is the shorter function syntax comparing with the traditional function. Let’s see an example for better understanding:

const add = (num1, num2) => {
// execute something
}

Spread operator

When we want to copy an object or array to create a new array or object we use the spread operator(…)

const A = [4, 5, 6];
const B = [...A, 7, 8, 9];
console.log(B) // [4, 5, 6, 7, 8, 9]

Object destructuring

It is the new feature of es6. Using this, we can easily get the value of properties of an object keeping the properties name same. See the example below for a better understanding.

const person = {name: 'Bill gates', age: 60};
const {name, age} = person; // Object Destructuring
console.log(name, age); // 'Bill gates', 60

So, guys, this is the end of today. Keep following for letter update.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Josesaurav
Josesaurav

Written by Josesaurav

Hi, every one am a javascirpt developer. I want to explore more about javascript everyday I try to share my thaughts to public.

No responses yet

Write a response