Javascript beginner must know!

Dev Shakib
4 min readMay 6, 2021

Expect that you appreciate this article! let’s get started!😎

Do you know?

JavaScript is high-level, often just-in-time compiled, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object orientation, and first-class functions.🏅

Today I am sharing some Javascript Concepts!

let’s get started!

1. Try…Catch

As a beginner or expert programmer. when executing JavaScript code, various mistakes could happen.

At the point when a mistake happens, JavaScript code will typically pause. But if you want to run code even get an error, this article is for you…

Syntax

try {
Block of code to try
}
catch(error) {
Block of code to handle errors
}

Code example

in this case, this code will stop executing after this alert(“code work !”)code. cause I am not defined the value of a

but if I use try…catch code didn't stop executing!

2.Data types

There are two data types in javascript

  1. Primitive data type
  2. reference data type

Six Data Types that are primitive

  • undefined
  • Boolean
  • Number
  • String
  • BigInt
  • Symbol

primitive values can`t be changed.

Code example

reference data type

  1. object
  2. function
  3. null
  4. array

in this case, you can change the value that you defined.

3.Coding Style

when you coding for your project, your code should be as clean and easy to read as possible. now I am showing some code example that is a good and bad habit.

Bad habits

Beginners programmers sometimes do this. In this case, Curly braces are not needed.

Good habits

That is perfect Curly braces are not needed in this case.

4.Comment in javascript

if you want to disable/comment any code line which is not executing, but you disable/comment to understand/explain the code that you wrote.

there are two types of comment

  1. single-line comment
  2. multiline comment

Single line comment

Multiline Comment

5.Arrow Function

The arrow function helps us to write shorter function syntax. it's introduced in ES6.be that as it may, is restricted and can’t be utilized in all circumstances.

BUT WHAT IS ES6?

ECMAScript is a general-purpose programming language, standardized by Ecma International according to the document ECMA-262. It is a JavaScript standard meant to ensure the interoperability of web pages across different web browsers.

.6 Spread Operator

ES6 has introduced many new features in JS. The spread syntax can be used when all elements from an object or array need to be copied to another variable. Using this operator makes the code concise and enhances its readability…

Syntax

Spread syntax (...)

Code example

.7 Var Declarations and Hoisting

.Hoisting is a default behavior In JavaScript. In JS, a variable can be announced/declared. after it has been utilized. In another word, a variable can be utilized before it has been announced/declared.

Code example

but if you want to use this system in ES6 let variable it can’t be possible.

8.Block-Level Declarations

Block-level declarations are those that declare variables that are inaccessible outside of given block scope.

9.Block Binding in Loops

Perhaps one area where developers most want block-level scoping of variables is within for loops, where the throwaway counter variable is supposed to be used only inside the loop. as an example, it isn’t uncommon to ascertain code like this

but if I use let instead of var i is not accessible here

--

--