2010-04-26 5 views

답변

3

에 미리

var lbp = { 

    // Pertinant page properties, such as Author, Keywords, URL or Title 
    page: { 
     theURL: window.location.toString(), 
    }, 

    // Configurable user defaults 
    defaults: { 
     creditText: lbp.page.theURL 
    } 
} 

덕분에 당신은하지 않습니다. lbp는 객체가 닫힐 때까지 현재 스코프의 심볼 테이블에 존재하지 않습니다.

var lbp = { 
    // Pertinant page properties, such as Author, Keywords, URL or Title 
    page: { 
     theURL: window.location.toString(), 
    }  
}; // NOW you can reference lbp by name 

lbp.defaults = { 
    creditText: lbp.page.theURL 
}; 
0

선언의 마지막 괄호가 닫혀 있기 때문에 lbp 변수가 정의되지 않았습니다.

0

값을 lbp 변수에 할당하기 전에 정의중인 개체의 내용이 해석되고 있다고 나는 생각합니다. 나는 별도의 지시에 값을 할당하지 않고 원하는 것을 할 방법이 없다고 생각합니다.

var lbp = {}; 
// Pertinant page properties, such as Author, Keywords, URL or Title 
lbp.page = { theURL: window.location.toString() }; 
// Configurable user defaults 
lbp.defaults = { creditText: lbp.page.theURL };