473,406 Members | 2,620 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,406 software developers and data experts.

noob question: what's a { doing there?

I'm a total noob, and I'm trying to understand this code:

var newsi = {
name:"newsi",
dom:false
};

newsi.Client=function(){
//stuff
}

I can't work out what datatype newsi is, I know you're gonna say
object but shouldn't it be one of number, string, boolean, null,
function, error, or something like that? It looks like a dictionary to
me but can a dictionary have a method called Client?

It's at the start of this file btw http://news.bbc.co.uk/js/newsi/latest/newsi.js?8
I've also seen: var foo = {};
That would be an empty.... what?
Apologies for my ignorance.

Thanks for your time in advance.

Jun 9 '07 #1
2 1467
VK
On Jun 9, 6:23 pm, tavspamno...@googlemail.com wrote:
I'm a total noob, and I'm trying to understand this code:

var newsi = {
name:"newsi",
dom:false

};

newsi.Client=function(){
//stuff

}

I can't work out what datatype newsi is, I know you're gonna say
object but shouldn't it be one of number, string, boolean, null,
function, error, or something like that?
Not necessarily. There can be Ford, Mazda, Ferrari - but all of them
are cars. Same can be Date, Array, Boolean but all of them also
extended in this or that way Object.
Also please note that numbers, strings, booleans and null are
primitives in Javascript, not objects (though you may use object
wrappers for them).

In your case you have new Object instance creation with some
properties and methods immediate instantiation over assignment.
Equivalent effect with longer but more clear syntax would be:

var newsi = new Object;
newsi.name = "newsi";
newsi.dom = false;
newsi.Client=function(){
//stuff
}

Don't forget that in Javascript object structure is dynamic and can be
changed at any time in any way even after the object's creation.
Jun 9 '07 #2
dd
On Jun 9, 4:23 pm, tavspamno...@googlemail.com wrote:
I'm a total noob, and I'm trying to understand this code:
They're using the newer style of Javascript syntax called JSON
(JavaScript Object Notation). If you google JSON you'll find a lot of
info on it. It's simply a different way of defining objects and their
properties/methods. The result though is identical to what would be
created by that code example you see in VK's answer. JSON has been
supported since about 1999 but only really became popular in the last
3 years or so.

Jun 10 '07 #3

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

Similar topics

10
by: Matt Hollingsworth | last post by:
Hello, Very new to python, so a noob question. When I've written stuff in JavaScript or MEL in the past, I've always adopted the variable naming convention of using a $ as the first character...
3
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open...
8
by: Ivan Shevanski | last post by:
Alright heres another noob question for everyone. Alright, say I have a menu like this. print "1. . .Start" print "2. . .End" choice1 = raw_input("> ") and then I had this to determine what...
4
by: foker | last post by:
I have an array with 50 elements in it, and a huge document with like 35,000 words on it. What I want to do is count the number of times each element has appeared in the document. This is what I...
0
by: AndyW | last post by:
Hey folks. I am trying to get a soap wsdl service working and have a bit of a noob php programming question for it. I'm using PHP 5.x btw. I have written a soap server that contains a...
9
by: Ben | last post by:
Hello, I'll bet this has been asked a million times but I can't seem to find a thread that gives the clear example I need. This PC has MySQL and IIS configured and running. The MySQL database is...
6
by: Lang Murphy | last post by:
I'm baaaaack... some of you answered a question I had last week. Only problem is: I'm a dope who doesn't understand most of what y'all posted. Raw noob when it comes to .Net and C#. So I'm going...
0
by: irtehnoob | last post by:
Hi there, I'm pretty new to c# (started up a few days ago) and I'm making a simple program, so far everything is going good except I can't figure somethine out.. hence why I'm here. Anyways, in my...
4
by: larry | last post by:
Ok I'm a Python noob, been doing OK so far, working on a data conversion program and want to create some character image files from an 8-bit ROM file. Creating the image I've got down, I open...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.