473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

javascript class syntax I have not seen before...

I have this book "Beginning JavaScript for Practical Web Development,
Including AJAX" and in it the author is using javascript syntax I
don't understand. It is

<class name>={
<function name>:function(params)
{
},
<function name>:function(params)
{
},
};

Here is a snippet of the actual code:

DOMhelp={
debugWindowId:'DOMhelpdebug',
init:function(){
// removed
},
lastSibling:function(node){
// removed
},
}

Are these static functions of the class DOMhelp or is something else
going on? Can someone provide me with a link that will expain this
notiation to me?

Cartoper

Oct 29 '07 #1
1 1781
On Oct 29, 11:36 am, Cartoper <carto...@gmail.comwrote:
I have this book "Beginning JavaScript for Practical Web Development,
Including AJAX" and in it the author is using javascript syntax I
don't understand. It is

<class name>={
That is an example of object literal notation that results in an
object being assigned to a (global) variable.

There are no classes in javascript (i.e. ECMAScript Language Ed 3)
although "class" is a future reserved word and there are plans to
introduce classes in the next version of ECMAScript. It is best not
to think of classes in regard to javascript, it just makes life more
difficult. You can emulate certain features of classes that exist in
other languages, however that does not make classes exist in
javascript.

All variables should be declared with var, though some are lazy and
don't bother for global variables. To me, it is much better to
explicity declare them:

var <object name= { ... };

It makes maintenance easier.

<function name>:function(params)
{
},
That creates a property called <function nameof the object <object
nameand assigns it a value of the function expression. You can call
it with:

<object name>.<function name>();
[...]
Are these static functions of the class DOMhelp or is something else
going on? Can someone provide me with a link that will expain this
notiation to me?
<URL: http://www.crockford.com/javascript/private.html >
--
Rob

Oct 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dan Webb | last post by:
Hi All, Im currently working on ways of pacakaging javascript functions/variables/objects in a similar way to the Java package statement so that scripts can be interact with each other with the...
1
by: jarit | last post by:
Hi, Found these coding guidelines for C#, HTML, Javascript, Java, HTML, PL/SQL, T-SQL, VB and VBScript. Well written and free to download. www.demachina.com/products/swat Jeroen
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
20
by: Neo Geshel | last post by:
I have been looking into Javascript libraries for the last week or two here, and there are certainly a lot of options out there. http://www.prototypejs.org/ http://mootools.net/...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.