2017-08-28 42 views

回答

3

它是一個變量聲明看見了。

這意味着,在短期:

var _ = this; 
var dataSettings; 
var responsiveSettings; 
var breakpoint; 

有沒有價值分配仍然會在你的範圍內都有效,並會使用時引發錯誤的變量。

參見這些3個例子之間的差別:1

實施例:

var foo; //is declared without value, aka undefined, is falsy 
if(foo){ 
    alert('This does not get called'); 
}else{ 
    alert('This gets called'); 
} 

實施例3:2

var foo = 'abcdefg'; // Declared with value 
if(foo){ 
    alert('Works'); 
} 

// No declaration 
if(foo){ // This will throw an error and your script stops executing. 
    alert('This does not get called'); 
} 
1

變量_被賦予值this。其餘的只是宣佈但未分配