Jump to content

New Class


jimfog

Recommended Posts

Take a look at this code here:

Slideshow=new Class({
I am confused. Does the above code create an abject? As far as i know the answer must be NO. As i know in javascript there are no classes. So, what the above code does? Is it maybe a class simulation technique?
Link to comment
Share on other sites

Javascript does have objects, in some sense or another, with methods and properties, private and public variables. If you scroll down a little, you'll see an explanation on this page: http://w3schools.com/js/js_objects.asp Javascript does not have inheritance or polymorphism, just object templates.

Link to comment
Share on other sites

I guess what you have up there, is a user defined Object: ex:
function class(){}

slideShow=new class

note that class is a reserved word in JS and cannot be used for variable names. although pretty useless as such, but still noteworthy.http://stackoverflow...d-in-javascript edit: and i believe it would either have to be
slideShow = new className();

or

slideshow = className;

Link to comment
Share on other sites

note that class is a reserved word in JS and cannot be used for variable names. although pretty useless as such, but still noteworthy.http://stackoverflow...d-in-javascript edit: and i believe it would either have to be
slideShow = new className();

or

slideshow = className;

Ok, you are saying that class is a reserved word. Then, why the developer uses it? It seems that there is not a problem with that. Unless i miss something here. Thanks.
Link to comment
Share on other sites

class is a reserved word. Class is not. JavaScript is case sensitive.
Oh, i had forgotten that, thanks for reminding
Though it's still probably not advisable to use it in either form (upper or lower case) because it could cause confusion to you or others who are trying to read your code.
Totally agree.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...