構文を教えて下さい。

[新着] Webテンプレートを仮オープンしました



0   名前: PAPA : 2007/07/10(火) 21:44  ID:FbMu1E0u sub-Ds
他人のサイトを除いていたところ、以下のようなソースを見つけました。
ブラウザの判断などを配列に入れているのだと思いますが、手持ちの書籍に記述もなく調べてもよくわかりませんでした。
”名称: XXXXX”のような場合のコロンの意味と使い方を教えてください。
よろしくお願いします。
var Info={
  Browser: {
  IE: !!(window.attachEvent && !window.opera),
  Opera:	!!window.opera,
  WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
  Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
  },

  BrowserFeatures: {
    XPath: !!document.evaluate,
    ElementExtensions: !!window.HTMLElement,
    SpecificElementExtensions:
    (document.createElement('div'). __proto__ !==
     document.createElement('form').__proto__)
  },
  emptyFunction: function() { }
}

1   名前: NullPo : 2007/07/10(火) 21:44  ID:Z0FHbpib sub-ii
http://ja.wikipedia.org/wiki/JSON

2   名前: 匿名 : 2007/07/10(火) 21:44  ID:AiQYbXzs sub-Cz
「ECMAScript Object 初期化子 連想配列」辺でぐぐる。
var o = new Object;
o.a = 1;
o.b = 'one';
o.c = new Object;
o.c.a = 2;
o.c.b = 'two';

// ↓

var o = { a : 1, b : 'one', c : { a : 2, b : 'two'} };
var Info = new Object;

Info.Browser = new Object;
Info.Browser.isIE     = ('ActiveXObject' in window);
Info.Browser.isOpera  = ('opera' in window);
Info.Browser.isSafari = ('konqueror' in window);
Info.Broser.isGecko   = ('netscappe' in window) && ('GeckoActiveXObject' in window);

Info.BrowserFeatures = new Object;
Info.BrowserFeatures.hasXPath = document.implementation.hasFeature ('XPath', '3.0');
Info.BrowserFeatures.hasElementExtensions = (typeof HTMLElement != 'undefined');

Info.emptyFunction = function () { ; };
var Info = {
    Broser : {
        isIE     : ('ActiveXObject' in window),
        isOpera  : ('opera' in window),
        isSafari : ('konqueror' in window),
        isGecko  : ('netscappe' in window) && ('GeckoActiveXObject' in window)
    },
    BrowserFeatures : {
        hasXPath : document.implementation.hasFeature ('XPath', '3.0'),
        hasElementExtensions : (typeof HTMLElement != 'undefined'),
    },
    emptyFunction : function () { ; }
};

3   名前: PAPA : 2007/07/10(火) 21:44  ID:FbMu1E0u sub-Ds
連想配列になるんですね。ググって見ます。
ありがとうございました。

一覧へ戻る