Symbols

Hi,

Was wondering what people thought about a kind of index page for symbols 
that are used (esp. JavaScript). A lot of programming books list such 
uses (and the Special:Allpages at the wiki would highlight any which had 
their own pages). For example, I just came across some code which uses 
left and right brackets on the left-hand side like this:

var [Channel] = load('chrome://...', 'Channel');

and wasn't sure how to go about finding how the brackets were being used 
here. A page could list symbols like brackets and explain or link to 
some of their uses (e.g., in arrays, etc.).

Brett


0
Brett
8/7/2008 6:07:10 PM
mozilla.dev.mdc 2326 articles. 0 followers. Post Follow

4 Replies
406 Views

Similar Articles

[PageSpeed] 28
Get it on Google Play
Get it on Apple App Store

On Aug 7, 2:07=A0pm, Brett Zamir <bret...@yahoo.com> wrote:


> A page could list symbols like brackets and explain or link to
> some of their uses (e.g., in arrays, etc.).

I think that's a great idea.  Would be a good addition to the Core
JavaScript Reference.

Eric Shepherd
Developer Documentation Lead
Mozilla Corporation
http://www.bitstampede.com/
0
Sheppy
8/7/2008 6:46:23 PM
Brett Zamir wrote:
> Hi,
> 
> Was wondering what people thought about a kind of index page for symbols 
> that are used (esp. JavaScript). A lot of programming books list such 
> uses (and the Special:Allpages at the wiki would highlight any which had 
> their own pages). For example, I just came across some code which uses 
> left and right brackets on the left-hand side like this:
> 
> var [Channel] = load('chrome://...', 'Channel');
> 
> and wasn't sure how to go about finding how the brackets were being used 
> here. A page could list symbols like brackets and explain or link to 
> some of their uses (e.g., in arrays, etc.).
> 
> Brett

Well? how are they being used?
0
John
8/8/2008 4:40:26 AM
Hi,

Actually, I don't know exactly--I was hoping someone might add it here 
or to the wiki! :)  (Now at 
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Symbols )

To take a simpler example (guessing the notation was simply a shorthand 
for adding a property to the global window object, I tried this:

var [foo] = 'zyxw';
alert(window.foo);

.....but it gives just 'z'.  Apparently, it grabs the first element out of 
an array and assigns it as a property of the global object using the 
name in brackets, as confirmed by this also:

var [foo] = [5, 2];
alert(window.foo); // Gives '5'

As far as I can tell, there's no way to use this syntax to add 'foo' as 
a property of some other object using this kind of shorthand. I still 
have no idea when this notation was made available, etc., etc.

Brett

John J. Barton wrote:
> Brett Zamir wrote:
>   
>> Hi,
>>
>> Was wondering what people thought about a kind of index page for symbols 
>> that are used (esp. JavaScript). A lot of programming books list such 
>> uses (and the Special:Allpages at the wiki would highlight any which had 
>> their own pages). For example, I just came across some code which uses 
>> left and right brackets on the left-hand side like this:
>>
>> var [Channel] = load('chrome://...', 'Channel');
>>
>> and wasn't sure how to go about finding how the brackets were being used 
>> here. A page could list symbols like brackets and explain or link to 
>> some of their uses (e.g., in arrays, etc.).
>>
>> Brett
>>     
>
> Well? how are they being used?
> _______________________________________________
> dev-mdc mailing list
> dev-mdc@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-mdc
>
>
>   

0
Brett
8/8/2008 7:13:52 AM
On Fri, Aug 8, 2008 at 11:13 AM, Brett Zamir <brettz9@yahoo.com> wrote:
> var [foo] = [5, 2];
> alert(window.foo); // Gives '5'
>
> As far as I can tell, there's no way to use this syntax to add 'foo' as
> a property of some other object using this kind of shorthand. I still
> have no idea when this notation was made available, etc., etc.
http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#Destructuring_assignment

Nickolay
0
Nickolay
8/8/2008 10:14:30 AM
Reply: