description

剛剛在論壇上看到, 記錄一下.
因為之前也想過這個問題, 原來是這麼使用法. 感恩~

codes

public class TestTime {}
}

Posted at 01:02上午 十一月 16, 2008 byshooeugenesea in Java  |  迴響[0]

JavaScript - expression

Best Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test Learning JavaScript

Best Math Test

Best Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test Learning JavaScript

Best Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test

reference

JavaScript 大全 - CH6

focal points

  1. else 會與最近的 if 成一對, 下面的例子中, else 是 testb 2 的 else
    var testb = false;
    if ( testb ) 
     alert( 'if testb 1' )
     if ( testb ) 
      alert('if testb 2');
    else
     alert('else');
     
     
  2. swich 除了跟 java 一樣的用法以外, 還可以和字串以及算式比較. 不過注意 case 是用 === 做比較, 而非 ==. 然後 default 可以放任一個位置, 只是只能有一個.
    function test() {}
    }
     
  3. for/in :
    1. for 迴圈可以用索引數把陣列一個個印出, for/in 則是可以把物件內容一個個印出.
    2. 使用 for/in 的時候, 會把物件的屬性名稱交給 for/in 宣告的暫存變數.
      function test() {};
       for ( var propName in obj ) {}
      }
       
    3. for/in 的暫存變數可以是計算式, 所以可以透過計算把物件屬性複製到其他陣列中.
      function test() {};
       var i = 0; 
       var cloneObjPropNames = new Array();
       for ( cloneObjPropNames[i++] in obj ) {}
       alert( cloneObjPropNames );
      }
       
    4. 如果屬性在迴圈中被刪除就不會列舉出來, 可是如果迴圈中定義新屬性會不會被列舉就看瀏覽器實做 (FireFox 測試是不會列舉).
      function test() {};
       for ( var propName in obj ) {}
      }
       
    5. for/in 並不會列舉物件的所有屬性, 唯讀, 永久保存, 不可列舉的屬性就無法列舉, JavaScript 內建屬性與 method 不會被列舉, 被繼承的使用者定義屬性會被列舉
      function TestObj() {} // 不被列舉
       TestObj.prototype.d = 2; // 會被列舉
       TestObj.prototype.e = function() {} // 會被列舉
      }
      function test() {}
       Date.prototype.custom = function() {} 
       for ( var propName in new Date() ) {}
       for ( var propName in new TestObj() ) {}
      }
       
  4. label 和 java 一樣用法. 且由於 label 和屬性或 function 名稱是無關的, 所以不用擔心 label 名稱和屬性或 function 名稱重複會有麼什麼問題.
    function test() {}
      }
     }
    }
     
  5. var
    1. 用 var 很方便的就是可以不限制變數的型態.
      function test() {}
      }
       
    2. 用 var 宣告的屬性無法 delete
      i = 1;
      var j = 0;
      function test() {}
       
  6. function
    1. function 通常定義在程式碼頂層, 或是在 function 內部的頂層. 也就是 function 不能定在 while 或 if 之類的區塊中.
    2. function 在編譯時期就會被 JavaScript 儲存起來, 這會造成一個現象就是如果 function 和變數名稱同名, 而引用該名稱的點又早於變數名稱的宣告位置, 則早於變數名稱宣告的引用點會看到 function, 而變數名稱宣告後的引用點會看到新宣告變數的內容
      function test() {}
       alert( r ); // 顯示 2
      }
       
  7. try/catch/finally
    1. 丟出例外的時候, 如果沒找到相對應的 catch 就會一直往外丟到有 catch 或是最外層, 到最外層都還沒有 catch 就會給 user 看到瀏覽器發出的 javascript 錯誤.
      function test() {} catch (error) {} finally {}
       }
       } catch (error) {} finally {}
      }
       
    2. 如果 finally 的時候執行 return, break, continue 等動作, 程式就會進入新的狀態.
      function test() {}
       } catch (error) {} finally {}
       }
      }
       
kBest Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test Learning JavaScriptv p Best Math Test Best Math Test sBest Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test Learning JavaScriptv f Best Math Test

Posted at 12:48上午 十一月 16, 2008 by shooeugenesea in JavaScript  |  迴響[0]

星期六 十一月 15, 2008

JavaScript - variable, operator and operand

Best Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test Learning JavaScript

Best Math Test

Best Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test Learning JavaScript

Best Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test

-1ee-1 Specifications Parts e 610 tsearchc Also P Best r Also s Also

401rd Best J Best va Bestmathtest c Test i Reversing t 401rd Bobcat t-1e Parts r Best hsearch Math et Parts Parts P-1r 610 s 610 searchoe Math Best lsearcho Bobcat -Ssearche-1i Love i Bestmathtest ati Test n Parts Best se-1rch 401rd searchpecsearchfcasearchins Reversing C-1each Best v Best rs 610 n Valve Parts searche 401rd e Reversing s Parts nsearch Parts 40searchr Parts 6search0 Reversing

focal points

  1. Declare
    1. 用 var 宣告變數, 如果宣告兩次其效果和宣告一次再 assign 值一次是一樣的
    2. 如果直接 assign 一個值到變數而沒有用 var 宣告, 比方說直接 abc = 1; 則 JavaScript 會自動替你宣告一個 global variable, 然後再讓你 assign 值
    3. 如果還沒 assign 值給某變數就要讀取變數值就會出錯. 比方說直接呼叫 alert( abc ); 就會有 abc is not defined 的錯誤
    4. JavaScript 區域變數有個特別的地方就是, 就算有同名的 global variable, 在 function 的最後才用 var 宣告某變數, 在宣告前 function 內使用到該變數的話並不會讀到 global variable, 而是會讀到未定義的 local variable
      var v = 'global variable';
      window.onload = function() {}
      alert( v ); // 先執行, 印出 global variable
       
  2. GC
    1. 和 Java 一樣, 如果 JavaScript 發現物件已經沒有變數指向物件, 則該物件的記憶體就會被回收
  3. Variable
    1. JavaScript 有 global object 和 local object, 如果你宣告一個 global variable 其實就是把變數宣告在 global object, 如果宣告 local variable 就是把變數宣告在 local object. 那還有情形是物件裡面還有物件, 其實一樣就是會有範圍更小的 local object. 當 function 在存取變數的時候, JavaScript 會從範圍最小的 local object 開始找起. 所以像是 Infinity 或是 parseInt 這些變數和 function 其實都是預先定義在 global object 裡面的東西.
    2. 使用 window 變數和最外層的地方使用 this 都是指定到 global object
    3. JavaScript 有執行環境就是 execution time, global object 有 global object 的執行環境, local object 也有自己的執行環境.
    4. 瀏覽器的不同視框也有自己的執行環境, 這些執行環境又可以互相溝通參考.
  4. 運算子.比較特別的運算子有 :
  5. fixed : 固定在瀏覽器上的某個位置
    /* outer 會固定在離瀏覽器頂端 100px 與瀏覽器左邊離 -60px, 所以會被瀏覽器左邊擋掉一點 */
    div#outer {} 
     
  6. relative : 與其他元素的相對位置加上偏移. 這個屬性和 absolute 與 fixed 都不同, 使用 relative 讓元素像是一般的元素一樣會被畫面上各種元素擠來擠去, 最後再加上指定的偏移量.
    /* outer 會跑到被擠壓過後的位置往下移 50px 往右移 20px */
    div#outer {} 
     
  7. 改變 li 項目清單的外觀.
    li#a {}
    li#b {}
    li#c {}
    li#d {}
    li#e {}
    
    /* A.XXX 
     * B.XXX
     * C.XXX
     */
    li#f {}
     
  8. 改變 li 控制 li 內的文字出現在標識下或文字下
    /* A.XXX
     *  XXX
     * B.XXX
     */
     li {}
    /* A.XXX
     * XXX
     * B.XXX
     */
     li {}
     
  9. 把 table 的水平邊框和垂直邊框設定成不同大小
    table#testid {} 
     
  10. 使邊框重疊
    /* 方法 1. 指定 border-spacing */
    table#testid {}
    /* 方法 2. 指定 border-collapse */
    table#testid {}
     
  11. 使 table 裡面的 table 的 th 背景為白色
    table table th {}
     
  12. 列印的時候套用另一組 CSS.
    <!-- 手攜裝置的 CSS -->
    <link rel="stylesheet" type="text/css" media="handheld" href="http://best-math-test-love.bestmathtest.com/q/Best/Math/Test/Best/ca/forhandheld.css" /> 
    
    <!-- 列印的 CSS -->
    <link rel="stylesheet" type="text/css" media="print" href="http://best-math-test-love.bestmathtest.com/q/Best/Math/Test/Best/ca/forprint.css" /> 
     
    1. 列印最好用點數如 12pt 來指定文字大小
    2. display 屬性可用來控制列印時候的特殊情形, 比方說不印就設 display : none
  13. kBest Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test Learning JavaScriptv p Best Math Test Best Math TestsBest Math Test Love Bestmathtest Best Math Test Ca 610 Bobcat Parts Also 401rd 6 Reversing Valve Parts Aldo 401rd 6 Reversing Valve Specifications Best Math Test Learning JavaScriptv f Best Math Test

    星期日 十月 26, 2008

    好文推薦 - Ajax waiter & Add EL in project & Thread pool & caching, parallelism and scalability

    Ajax Waiter
    Adding EL support on your projects
    Creating a NotifyingBlockingThreadPoolExecutor
    Caching, Parallelism and Scalability
    Using JSF and Flex Components Together

    星期六 十月 18, 2008

    SQL - 查詢每天最後一筆

    description

    很少用 SQL, 結果遇到一個需求就想很久..
    關於查詢每天的最後一筆這種好像蠻常見的需求, 上網卻沒看到什麼解法.
    不過還好最後有做出來, 雖然醜醜的.
    在這分享一下.
    不過這一定是個破解法, 希望有人可以提供更好的解法, 謝謝..
    ps. 這個是 derby 的語法

    SQL

    我有一個 table, 有三個欄位, ID 是用 UUID
    create table TEST_DATE (
     ID varchar(40), 
     EMP_ID varchar(40), 
     MY_DATE timestamp
    )
    
    然後我的需求是, 找出某個 EMP_ID 每天的最後一筆資料, 結果就是
    select * from TEST_DATE d2 where d2.MY_DATE in (
     select MAX_DATE from ( (
     select DATE(d.MY_DATE) DAY, max(d.MY_DATE) MAX_DATE 
     from TEST_DATE d 
     where d.EMP_ID = '123456'
     group by DATE(d.MY_DATE) 
     ) T
    ) )
    



    A blog by
    shooeugenesea

    search

    + 加法 如果其中一個運算元是字串, 另一個就也會轉字串, 如 alert( 5 + '6' ); 會印出 '56'. 為什麼加號遇到字串就不算數字結果而是字串串起來是因為 + 的字串運算元優先權大於數字運算元, 所以 '1' + '2' = '12'.
    另外 + 運算子是由左到右, 所以 1 + 2 + 'test' = '3test' 而 'test' + 1 + 2 = 'test12'
    = 指定運算子 = 是由右向左的結合性, 總之就是又變的值為主, 目前一直是這樣.
    += 加並指定 += 除了可計算數字以外還可用在字串上
    - * % 減法 乘法 求餘數 如果運算元不是數字就會被轉成數字
    - + 減號加號