What You Need to Know About JavaScript

Lahaduzzaman Lahad
4 min readMay 6, 2021

JavaScript is an open-source and most popular client-side scripting language supported by all browsers. JavaScript is mainly used for enhancing the interaction of the webpage with users by making it more lively and interactive. It is also used for game development and mobile application development.

Today we will discuss some basics core concepts of JavaScript. Here I explain the core concepts of them:

Primitive Values: Primitive values are data that are stored on the stack. It is stored directly in the location that the variable accesses.JavaScript has six primitive data types: String, Number, Boolean, Null, Undefined, Symbol. With the exception of null and undefined, all primitives values have object equivalents that wrap around the primitive values.

  1. Boolean: Yes or No.
  2. Number: Any type of number(2,0,-45,5.7, others).
  3. String: Any type of text(dog, mango, cricket, others).
  4. Undefined: It is unintentionally missing values.
  5. Null: It is used for intentionally missing values.
  6. Symbols: It is used to hide implementation details.

Cross-Browser Testing: Cross Browser testing is a type of non-functional testing that lets you check whether your website works as intended when accessed through:

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.

Coding Style: Coding style is the art of programming. It’s not easy to pick a hard work, solve it using programming & also keeping it human-readable & self-explanatory. This is why the idea of ‘Coding Style’ comes in. Large projects need to be coded in a consistent style. It’s not only helping us to make the code easier but also ensuring that any developer who looks at the code will know what should he expect from the entire application.

Indentation in JavaScript: Many developers choose to use 4-space or 2-space indentation. In JavaScript, each nested statement (e.g., a statement following a “{“ brace) should be indented exactly once more than the previous line’s indentation. Here are some examples of bad indentation in JavaScript:

Bad Use
Good Use

Spacing in JavaScript: Place a space between operators, assignments (“=”), and their operands.

//Bad Use
let x=(a+b)*c/d+foo();
//Good Uselet x = (a + b) * c / d + foo();

Comment in JavaScript: Good Comments in Coding is very important when another developer is going to review your code or when you’re working on a team. But don’t overuse the power of comments. Sometimes “that” other coder is your future self. Don’t comment explaining the code. Because good code is self-documenting. Comments can be single-line: starting with // and multiline: /* ... */.

Block Binding in Loops: This is one area where developers most want block-level scoping of variables is within for loops, where the throwaway counter variable is meant to be used only inside the loop. For for this we have to use let not var, cause var is being hoisted. Follow the two examples below:

for (var i = 0; i < 20; i++) {
process(items[i]);
}
// i is still accessible here
console.log(i);
// 20

The variable i is still accessible after the loop is completed because the var declaration gets hoisted. Using let instead, as in the following code to ignore this problem:

for (let i = 0; i < 20; i++) {
process(items[i]);
}
// i is not accessible here – throws an error
console.log(i);

In this example, the variable i only exists within the for loop.

Global Block Bindings: Another way in which let and const are different from var is in their global scope behavior. When var is used in the global scope, it creates a new global variable, which is a property on the global object. That means you can accidentally overwrite an existing global using var.

Example:

Arrow Function in ES6: Arrow functions make our code better looking, and simplify function scoping and the this keyword. By using the arrow function we avoid having to type the function keyword, return keyword, and curly brackets.

Example:

var Name = (firstName,lastName) => firstName + lastName;

Functions with Default Parameter Values: In JavaScript, function parameters default to undifined. However, it's often useful to set a different default value.

Example:

That’s all from me. Hope you get a good idea about the basics core concepts of JavaScript from this. I will come with more articles in the next few days. Till then stay tuned and follow me.

Thank You ♥️

--

--