There are some tricky things in JavaScript which might be confusing sometimes. Let’s explore them…

Image for post
Image for post
Photo by AltumCode on Unsplash

Truthy and Falsy

Every number in JavaScript is truthy except “0”. If a variable contains “0”, then it’s a falsy value. You can check them…

So here we can see that all natural numbers are truthy except zero(0).

In JavaScript, every string is truthy except an empty string (“”). If a variable contains an empty string, then it’s a falsy value. …


What is JSX and why should you learn it? Let’s talk about it.

Image for post
Image for post
Photo by Ferenc Almasi on Unsplash

JSX looks like a regular HTML in most cases. JSX is an HTML-like syntax used by React that extends ECMAScript so that HTML-like text can co-exist with JavaScript/React code. The syntax is intended to be used by preprocessors (i.e., transpilers like Babel) to transform HTML-like text found in JavaScript files into standard JavaScript objects that a JavaScript engine will parse.

By using JSX you can write HTML-like structures in the same file as you write JavaScript code, then Babel will transform these expressions into actual JavaScript code. …


Programming languages all have built-in data structures, but these often differ from one language to another. JavaScript also has its own data types. These can be used to build other data structures.

Image for post
Image for post
Photo by Ferenc Almasi on Unsplash

1) Primitive Values

Primitive Values​ are numbers and strings, among other things. It can contain only a single thing (be it a string or a number or whatever).

Number

The number type in JavaScript represents both integer and floating-point numbers. There are many operations for number type, e.g. multiplication (*), division (/), addition (+), subtraction (-), and so on.

BigInt

A BigInt value is created by appending n to the end of an integer. In JavaScript, the “number” type cannot represent integer values larger than (2^53–1) (that’s 9007199254740991), or less than -(2^53–1) for negatives. …


Wanna speed up your works with arrays in JavaScript to save time? Check out these 10 Tips & Tricks which will literally speed up your coding.

Image for post
Image for post
Photo by Pakata Goh on Unsplash

JavaScripts comes with some amazing methods to play with the array. Let’s explore them…

1) map()

What you usually do when you have to iterate through every item in an array? Most probably you run for loop in that array. But there is a method built-in with JavaScript which is called map(). Here is an example of it.

The map method takes an argument which is every element of an array. Then it does some operations with that element and returns a new array.

2) filter()

The filter method is used when you have to filter some elements from an array if they pass the test implemented by the provided function. It is helpful when you have a large array and want to filter some items of the same category. Let’s see how it…


Every programming language has a Style Guide of its own. A style guide is an opinionated guide of programming conventions, style, and best practices for a team or project.

Image for post
Image for post
Photo by Ferenc Almasi on Unsplash

JavaScript also has a worldwide acknowledged style guide which is made by Air BNB. This style guide teaches us the good practices and bad practices of JavaScript. But most new developers are not aware of it. That’s why I’m writing this post about 10 best practices of JavaScript. Hope you will enjoy it.

1) Best Practices of Variable

In JavaScript, you can declare a variable using three keywords. These are var, const, and let. Now you might be thinking, “What is the difference between these keywords? These do the same thing which is declaring a variable.” No, they are not the same. Let’s see this example below…

In modern JavaScript, we don’t use var. Rather we use let and const. The only difference between let and const is, you can change the value of a variable which has declared using let but you can’t change the value of a variable which has declared using const. …


Wanna develop your JavaScript coding skills and save time during coding? Check out these 10 Tips & Tricks which will simplify your code and make you a smart developer.

10 Tips & Tricks For New JavaScript Developers
10 Tips & Tricks For New JavaScript Developers
Photo by Shahadat Rahman on Unsplash

Let’s get started.

1) Use let or const instead of var

You should use let or const when you define a variable. You might be asking, “Why should I do that?” Let’s see some examples of differences between let, const, and var then you will get your answer.

Here you can see that by declaring a variable using the var keyword, you can call it outside of the block where you have declared that variable.

But what if you use let keyword instead of var? …

About

Sadman Sakib Mugdho

Full Stack Web Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store