目前分類:javascript (4)

瀏覽方式: 標題列表 簡短摘要
  1. var Db = function() {
  2. //private fields
  3. var member = "private fields";
  4. // public fields
  5. this.menber = "public fields"
  6. //constructor
  7. constructor = function() {
  8. alert(member);
  9. }
  10. //private methods
  11. methods = function() {
  12. alert(member);
  13. //public methods
  14. this.methods = function() {
  15. alert(member);
  16. }
  17. //do constructor
  18. constructor();
  19. }

  20. var idb = new Db();

benjamin16pp 發表在 痞客邦 留言(0) 人氣()

在function中定義的function,內部的function可以存去外部function內定義的變數,這樣叫做Closure

benjamin16pp 發表在 痞客邦 留言(0) 人氣()

在js中邏輯運算中,0、""、null、false、undefined、NaN2. 都判定是false,其他則是true


benjamin16pp 發表在 痞客邦 留言(0) 人氣()

index = '1';

var val = {'1':'One','2':'Two','3':'Three','4':'Four'}[index] || 'none'; 

benjamin16pp 發表在 痞客邦 留言(0) 人氣()