DEV Community


Most Important Concept in JavaScript

・2 min read

For Coding with JavaScript, You must know some concepts from them I descript important 10 here.

  1. True or False Value
  2. String: In JavaScript, we can check value true or false event when value is a string. Every String that has length it's true if there is nothing but there are is white space it's a true value, because of white space its length is 1 and an empty string is false.
  • Number: In javaScript condition 0 is the value of false, every others value is true even it's negative.
  • Variable: When a variable value is null or NaN it's false.
  1. Double Equal, Triple Equal When two or three values check with double equal (==) then it checks the value and gives the result true or false.

expamle: if(10 == "10"){
console.log("it's true")
console.log("it's false")

result: it's true,

double equal (==) check only value that's why it logs true.

but when we check with triple equal (===) its log false. because the first 10 is a number and the second "10" is a string their type is not the same triple equal check the value and check the type their value is same but their type is different that's why
It logs false.

expamle: if(10 === "10"){
console.log("it's true")
console.log("it's false")

result: it's false,

  1. Scope there is two scopes in JavaScript, 1. block Scope, 2. Global Scope. when we declare a variable in a function with const or let then the variable is block Scope variable, it's can not be found from outside the function.

when we declare a variable outside of the function that is global scope we can use it In under the function or outside of the function.

if we declare a variable in a function with the word "var" then we can access the variable from outside of the function, that case when starting the javaScript scan the whole page and the variable declared with "var" it converts to global scope that's why we can access.

  1. This Keyword
    when we call this keyword in any function then this means the function, this keyword represents this parent.

  2. Asynchronous
    JavaScript works synchronize or serial wise, but we can make it asynchronous wise, for that we can use setTimeout.
    with setTimeout we can call a function after a certain time. when we use it javaScript is no longer synchronous.

Discussion (0)

Forem Open with the Forem app