Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Web Developer Interviews:BootstrapFront End Web DeveloperHTML DeveloperHybrid Application DeveloperInternee PHP DeveloperJnr PHP/Codeigniter DeveloperJunior Developer PHPLaravel PHP DeveloperPython DeveloperRuby DeveloperTypographyWeb Developer & DesignerWeb Developer Cum SEO AnalystWeb Development NinjasWebsite DeveloperWordPress Themes Developer
Copyright © 2018. All Rights Reserved
Website Developer Interview Question:
Do you know what Is Scope In JavaScript?
Submitted by: MuhammadThe general meaning of scope is the accessibility of functions and variables in an application. Usually, we use them in two ways i.e. Local and Global.
A) Local Scope.
If we declare a function or variable inside a function, then we can access it only inside that function.
// code here can not use myLocalVar
function myFunction() {
var myLocalVar = "I'm Local";
// code here can use myLocalVar
}
B) Global Scope.
Declaring a variable anywhere on the page would mean that we can access it from any of the functions on that page.
var myGlobalVar = "I'm Global";
// code here can use myGlobalVar
function myFunction() {
// code here can use myGlobalVar
}
Submitted by: Muhammad
A) Local Scope.
If we declare a function or variable inside a function, then we can access it only inside that function.
// code here can not use myLocalVar
function myFunction() {
var myLocalVar = "I'm Local";
// code here can use myLocalVar
}
B) Global Scope.
Declaring a variable anywhere on the page would mean that we can access it from any of the functions on that page.
var myGlobalVar = "I'm Global";
// code here can use myGlobalVar
function myFunction() {
// code here can use myGlobalVar
}
Submitted by: Muhammad
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.