2 min read

Must-Know JavaScript Concepts You Shouldn’t Miss as a Web Developer

JavaScript is a leather sheath with a really really sharp knife inside. That knife can cut anything, and with it, you can do anything.
Must-Know JavaScript Concepts You Shouldn’t Miss as a Web Developer

So here are a few JavaScript concepts that you should know:

1. Traversing the DOM

The Document Object Model (DOM) is a programming interface for HTML and XML documents. It is an API that allows developers to make changes in HTML by using JavaScript. This concept is the key to building dynamic websites and helps in linking HTML and JavaScript on the frontend.

Understanding how to traverse the DOM using JS is indeed one of the essential skills needed in web development.

2. Scope

The scope is an important concept in JavaScript to understand since it determines the lifespan, access, and visibility of variables, functions, and objects throughout your code and provides security by putting certain restrictions..

In the JavaScript language there are two types of scopes:

  • Global Scope: A variable that is declared outside of any function and can be accessed and modified from any function.
  • Local Scope: A local variable is a variable that is declared within a function and can only be accessed within that function.

3. Closures

A closure is a function that has access to the variable from another function’s scope which is accomplished by creating a function inside a function.

Example:

function Spellname(name) {
var greet = "Hi, " + name + "!";
var sName = function() {
var welc = greet + " Good Morning!";
console.log(greet);
};
return sName;
}
var Myname = SpellName("Nishi");
Myname(); // Hi, Nishi. Good Morning!

In the above example, the function sName() is closure; it has its own local scope (with variable welc) and also has access to the outer function’s scope. After the execution of Spellname(), the scope will not be destroyed and the function sName() will still have access to it.

4.Value vs. Reference Variable Assignment

JavaScript always assigns variables by value. The actual value is assigned when the assigned value happens to be one of JavaScript’s five primitive types i.e., boolean, null, undefined, string and number.

However, a reference to the object in memory is assigned when the assigned value happens to be JavaScript’s three data types that are copied by having their reference copied: Array, functions, object.

5.Hoisting

In JavaScript, hoisting is a behavior in which a function or a variable can be used before declaration.

eg: dog('bark');
function dog(sound){
 console.log(sound);
}

Better Programming
Advice for programmers.
source:https://betterprogramming.pub/

#Programming #WebDeveloper #Tips #Javascript #Probyto #ProbytoAI

Subscribe and follow us for latest news in Data Science , Machine learning and technology and stay updated!
Facebook: https://facebook.com/probyto
Twitter: https://twitter.com/probyto
LinkedIn: https://linkedin.com/company/probyto
Instagram: https://instagram.com/probyto