簡體   English   中英

誰能解釋Visual Studio Javascript智能感知的這種行為?

[英]Can anyone explain this behaviour of Visual Studio's Javascript intellisense?

前段時間編寫Javascript繼承函數時,我注意到Visual Studio中的intellisense有一些非常奇怪的行為,我認為沒有其他地方對此進行了記錄。 到目前為止,我已經在VS2008和VS2010中觀察到了這一點,但據我所知,它可以追溯到更早。

基本上,VS似乎正在執行一個功能並使結果可在智能感知中使用。

例如:

function test(obj, member, value) {
    obj[member] = value;
    return obj;
}

function harness() {
    var obj = {};
    test(obj, "firstname", "Jack");
    test(obj, "lastname", "Bauer");
    // If you now type in 'obj.' and wait for intellisense to pop-up you will notice that 'firstname' and 'lastname' will appear as members.
}

在我的一生中,我無法弄清楚使用常規語法檢查器如何做到這一點-VS在不執行“ test()”的情況下無法知道“名字”或“姓氏”是對象成員嗎? t個成員,直到調用該函數。

有人可以提出解釋嗎?

VS intellisense確實確實執行了代碼(無論如何都是偽執行)。

看看這個: http : //weblogs.asp.net/scottgu/archive/2010/04/08/javascript-intellisense-improvements-with-vs-2010.aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM