Compare Revisions

Dict.jsm

Change Revisions

Revision 339733:

Revision 339733 by teoli on

Revision 340729:

Revision 340729 by hobophobe on

Title:
Dict.jsm
Dict.jsm
Slug:
Mozilla/JavaScript_code_modules/Dict.jsm
Mozilla/JavaScript_code_modules/Dict.jsm
Tags:
JavaScript, Modules
"Modules", "JavaScript"
Content:

Revision 339733
Revision 340729
n26      If you wish, you may also pass in an array of key/value pain26      If you wish, you may also pass in an <a href="/en/JavaScrip
>rs with which to initialize the dictionary:>t/Guide/Values,_variables,_and_literals#Object_literals" title="e
 >n/JavaScript/Guide/Values,_variables,_and_literals#Object_literal
 >s">object literal</a> of key/value pairs with which to initialize
 > the dictionary:
nn38    <p>
39      In Firefox 19 and above, you may also pass a <a href="/en/J
 >SON" title="en/JSON">JSON String</a> to initialize the dictionary
 >:
40    </p>
41    <pre>
42var someJSON = '{key1: "foo", key2: {}}';
43var newDict = new Dict(someJSON);
44</pre>
45    <div class="note">
46      <strong>Note:</strong> Any String you pass will be assumed 
 >to be JSON.
47    </div>
n45            <code>Dict <a href="/en/JavaScript_code_modules/Dict.n55            <code>Dict <a href="/en/JavaScript_code_modules/Dict.
>jsm#copy()" title="en/JavaScript code modules/Dict.jsm#copy()">co>jsm#copy()" title="en/JavaScript code modules/Dict.jsm#copy()">co
>py</a>();<br></code>>py</a>();</code>
n55            <code><a href="/en/JavaScript/Reference/Global_Objectn65            <code><a href="/en/JavaScript/Reference/Global_Object
>s/Object" title="en/JavaScript/Reference/Global Objects/Object">O>s/Object" title="en/JavaScript/Reference/Global Objects/Object">O
>bject</a> <a href="/en/JavaScript_code_modules/Dict.jsm#get()" ti>bject</a> <a href="/en/JavaScript_code_modules/Dict.jsm#get()" ti
>tle="en/JavaScript code modules/Dict.jsm#get()">get</a>(</code><c>tle="en/JavaScript code modules/Dict.jsm#get()">get</a>(</code><c
>ode><a href="/en/JavaScript/Reference/Global_Objects/String" titl>ode><a href="/en/JavaScript/Reference/Global_Objects/String" titl
>e="en/JavaScript/Reference/Global Objects/String">String</a></cod>e="en/JavaScript/Reference/Global Objects/String">String</a></cod
>e> <code>aKey</code><code>, [optional]</code> <code><a href="/en/>e> <code>aKey</code><code>, [optional]</code> <code><a href="/en/
>JavaScript/Reference/Global_Objects/Object" title="en/JavaScript/>JavaScript/Reference/Global_Objects/Object" title="en/JavaScript/
>Reference/Global Objects/Object">Object</a></code> <code>aDefault>Reference/Global Objects/Object">Object</a></code> <code>aDefault
>);<br></code>>);</code>
n65            <code>Array <a href="/en/JavaScript_code_modules/Dictn75            <code>Array <a href="/en/JavaScript_code_modules/Dict
>.jsm#listitems()" title="en/JavaScript code modules/Dict.jsm#list>.jsm#listitems()" title="en/JavaScript code modules/Dict.jsm#list
>items()">listitems</a>();<br></code>>items()">listitems</a>();</code>
66          </td>
67        </tr>
68        <tr>
69          <td>76          </td>
77        </tr>
78        <tr>
79          <td>
70            <code>Array <a href="/en/JavaScript_code_modules/Dict80            <code>Array <a href="/en/JavaScript_code_modules/Dict
>.jsm#listkeys()" title="en/JavaScript code modules/Dict.jsm#listk>.jsm#listkeys()" title="en/JavaScript code modules/Dict.jsm#listk
>eys()">listkeys</a>();<br></code>>eys()">listkeys</a>();</code>
71          </td>
72        </tr>
73        <tr>
74          <td>81          </td>
82        </tr>
83        <tr>
84          <td>
75            <code>Array <a href="/en/JavaScript_code_modules/Dict85            <code>Array <a href="/en/JavaScript_code_modules/Dict
>.jsm#listvalues()" title="en/JavaScript code modules/Dict.jsm#lis>.jsm#listvalues()" title="en/JavaScript code modules/Dict.jsm#lis
>tvalues()">listvalues</a>();<br></code>>tvalues()">listvalues</a>();</code>
76          </td>
77        </tr>
78        <tr>
79          <td>86          </td>
87        </tr>
88        <tr>
89          <td>
80            <code>void <a href="/en/JavaScript_code_modules/Dict.90            <code>void <a href="/en/JavaScript_code_modules/Dict.
>jsm#set()" title="en/JavaScript code modules/Dict.jsm#set()">set<>jsm#set()" title="en/JavaScript code modules/Dict.jsm#set()">set<
>/a>(String</code> <code>aKey</code><code>,</code> <code><a href=">/a>(String</code> <code>aKey</code><code>,</code> <code><a href="
>/en/JavaScript/Reference/Global_Objects/Object" title="en/JavaScr>/en/JavaScript/Reference/Global_Objects/Object" title="en/JavaScr
>ipt/Reference/Global Objects/Object">Object</a></code> <code>aVal>ipt/Reference/Global Objects/Object">Object</a></code> <code>aVal
>ue);<br></code>>ue);</code>
81          </td>
82        </tr>
83        <tr>
84          <td>91          </td>
92        </tr>
93        <tr>
94          <td>
85            <code><a href="/en/JavaScript/Reference/Global_Object95            <code><a href="/en/JavaScript/Reference/Global_Object
>s/String" title="en/JavaScript/Reference/Global Objects/String">S>s/String" title="en/JavaScript/Reference/Global Objects/String">S
>tring</a></code> <code><a href="/en/JavaScript_code_modules/Dict.>tring</a></code> <code><a href="/en/JavaScript_code_modules/Dict.
>jsm#toString()" title="en/JavaScript code modules/Dict.jsm#toStri>jsm#toString()" title="en/JavaScript code modules/Dict.jsm#toStri
>ng()">toString</a>();<br></code>>ng()">toString</a>();</code>
96          </td>
97        </tr>
98        <tr>
99          <td>
100            {{ fx_minversion_inline("19") }}<code><a href="/en/Ja
 >vaScript/Reference/Global_Objects/String" title="en/JavaScript/Re
 >ference/Global Objects/String">String</a></code> <code><a href="/
 >en/JavaScript_code_modules/Dict.jsm#toJSON()" title="en/JavaScrip
 >t code modules/Dict.jsm#toJSON()">toJSON</a>();</code>
n259<code>Object get(<br>  String </code><code>aKey</code><code>,<br>n274<code>Object get(
>  [optional] Object aDefault<br>);</code> 
275  String </code><code>aKey</code><code>,
276  [optional] Object aDefault
277);</code>
n291<code>boolean has(<br>  String </code><code>aKey<br></code><code>n309<code>boolean has(
>);</code> 
310  String </code><code>aKey
311</code><code>);</code>
n389<code>void set(<br>  String </code><code>aKey</code><code>,<br>  n409<code>void set(
>Object aValue<br>);</code> 
410  String </code><code>aKey</code><code>,
411  Object aValue
412);</code>
tt451    </p>
452    <h2 id="toJSON()">
453      toJSON()
454    </h2>
455    <p>
456      Returns a <a href="/en/JSON" title="en/JSON">JSON String</a
 >> representation of the dictionary.
457    </p>
458    <pre>
459String toJSON();
460</pre>
461    <h6 id="Parameters">
462      Parameters
463    </h6>
464    <p>
465      None.
466    </p>
467    <h6 id="Return_value">
468      Return value
469    </h6>
470    <p>
471      A JSON String representation of the dictionary's key/value 
 >pairs. This will be "{}"&nbsp;for an empty dictionary.

Back to History