Global scope means that if you declare any variable using var and outside of any block, then you can access that variable from anywhere in your code.
.2 Local Scope
Local scope means if you declare any variable inside any function, you don’t use that function outside of that function. If you want to use that local variable, you have to use it inside the function.
We can see that we can’t access the local variable from the outside of that function.
3. Function Scoped
In a function block, you can access variables from everywhere inside your function.
But you can’t access any variable which declares the inside function block from the outside of the function block.
And the solution using Let make that variable blocked scoped.
Hoisting means pulling the variable to the top. Let’s see on the code.
But if we change our code, we use console log before the declaration of hostingTest Then on that time, and the engine does one thing it cut the var and take a name like hostingTest in top & set it as a var variable but do not assign any value for that it trow undefined error.
but again, we use console log after assign the hostingTest variable, and it will give the output
We can see that when that code finds an undefined variable, it was stoped, not move forward from the second line. So we want that handle this error and run the full code after getting the error and also get the message for which reason we got this error for that we can use try-catch
So we can see after getting the error, the compiler moves forward 7 what kind of error occurred. We can check that.
Inside the catch function, you have to set a parameter, and it can err, error whatever you want. Using that if you want to see only error name, you will use
or, if you want to see the error message, you have to use
If you want to show something to your user, whatever there is any error o occurred or not. So do that thing after using try-catch
8.Cross Browsing Testing
Cross browsing testing means ensuring that your web project or app works properly in an acceptable number of browsers, devices, whatever it’s, .so that users can get more satisfaction from your site or app. If your site is working well in your browser like chrome, this is your responsibility to ensure that your site works properly in another browser like opera, safari, Mozilla as same as yours.
9.Reasons why happed cross browsing issues
I.Some times the browser application has bugs.
II.Different browsers use different technology.
IV.No Reset CSS
The spread operator is the most useful thing in JS. You can compare it with concat. It’s basically used on an array. It uses using three-dot(…). After using that, you can merge a new element with your existing array.
Spread operator doing the concat job
That’s it for today we will meet very soon with some new interesting things.