jimfog Posted September 29, 2011 Share Posted September 29, 2011 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 More sharing options...
Ingolme Posted September 29, 2011 Share Posted September 29, 2011 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 More sharing options...
Drycodez Posted September 29, 2011 Share Posted September 29, 2011 I guess what you have up there, is a user defined Object: ex: function class(){} slideShow=new class Link to comment Share on other sites More sharing options...
thescientist Posted September 29, 2011 Share Posted September 29, 2011 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 beslideShow = new className(); or slideshow = className; Link to comment Share on other sites More sharing options...
jimfog Posted September 29, 2011 Author Share Posted September 29, 2011 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 beslideShow = 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 More sharing options...
ShadowMage Posted September 29, 2011 Share Posted September 29, 2011 class is a reserved word. Class is not. JavaScript is case sensitive. 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. Link to comment Share on other sites More sharing options...
jimfog Posted September 29, 2011 Author Share Posted September 29, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.