Home Tutor
05/01/2022
https://www.freecodecamp.org/news/html-best-practices/
HTML Best Practices – How to Build a Better HTML-Based Website HTML is the backbone of any website. It's the first thing people see. Without it, there would be no website. Because of this, it's important that you stick to good coding practices. If you don't follow the best practices, you will create a bad user experience for the web user.
Understanding Scope in JavaScript
A simple definition for a scope in JavaScript:
Scope is the accessibility of variables, functions, and objects in some particular part of your code during runtime. In other words, scope determines the visibility of variables and other resources in areas of your code.
As per the above definition of Scope, So, the point in limiting the visibility of variables and not having everything available everywhere in your code.
the scope is defined in the main two ways,
Global Scope
Local Scope
var greeting='Welcome to blog';
(function(){
console.log(greeting); //Output: Welcome to blog
})();
consider above code greeting variable should be global scope, it can access inside the function,
(function(){
var greeting = 'Welcome to blog';
console.log(greeting); //Output: Welcome to blog
})();
console.log(greeting); //Output:Reference-Error greeting not defined
In the above code for local scope,
In scope level variables in JavaScript ES6 has updated hoisting variable let, var, const type check with that, In order to learn the scope, you need to understand hoisting also
Click here to claim your Sponsored Listing.
Category
Website
Address
Lahore