Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript variable scope in if statement

var foo = "test";
if(true) {
    alert(foo); // Interviewer: "What does this alert?" Answer: "test"
    var foo = "bar";
}
alert(foo); // "bar" Interviewer: Why is that? Answer: Because JavaScript does not have block scope
Comment

PREVIOUS NEXT
Code Example
Javascript :: Backbone Model Setting, Has And Getting 
Javascript :: &quot in json 
Javascript :: how to validate date in react js 
Javascript :: how to get on hnage input before clicking off 
Javascript :: name of javascript virtual machine for apple 
Javascript :: Different Pages For Different Routes In Backbone 
Javascript :: Populate a Select Dropdown List using JSON 
Javascript :: simple JSX example 
Javascript :: for-loop-how-to-loop-through-an-array-in-js 
Javascript :: react native long form up input 
Javascript :: remove parent element jquery 
Javascript :: empty an array in javascript 
Javascript :: js 1 second sleep 
Javascript :: redirect in react-router-dom v6 
Javascript :: ar.js 
Javascript :: moment duration 
Javascript :: jsx attributes 
Javascript :: subarray javascript 
Javascript :: calculate jwt expire time 
Javascript :: _.union 
Javascript :: rem api rest 
Javascript :: useThrottle 
Javascript :: javascript Adding Element to the Outer Array 
Javascript :: javascript of the object properties to a single variable 
Javascript :: javaScript values() Method 
Javascript :: jQuery - Set 
Javascript :: OpenTok Create Session 
Javascript :: Javascripti functions accepting Flask parameters to display a PDF file with Adobe Embed API 
Javascript :: phaser export animation to json 
Javascript :: Exercice âge JavaScript 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =