runeveryday Posted June 29, 2010 Share Posted June 29, 2010 why everybody says "everything is an object" in javascript. can't understand this sentence, hope someone can explain it to me. the more detail,the better. Link to comment https://forums.phpfreaks.com/topic/206146-everything-is-an-object/ Share on other sites More sharing options...
trq Posted June 29, 2010 Share Posted June 29, 2010 Because unlike php where there are different data types all data within Javascript is an object. eg; You can call methods on a string because it is a string object. 'this is a string set to uppercase'.toUpperCase(); Link to comment https://forums.phpfreaks.com/topic/206146-everything-is-an-object/#findComment-1078585 Share on other sites More sharing options...
haku Posted June 29, 2010 Share Posted June 29, 2010 That's exactly it. Objects can have methods and properties. Anything in javascript can have a method or a property attached to it (including functions, strings, or anything else). So everything is an object! Link to comment https://forums.phpfreaks.com/topic/206146-everything-is-an-object/#findComment-1078587 Share on other sites More sharing options...
runeveryday Posted June 29, 2010 Author Share Posted June 29, 2010 thank u,i am also confused. Link to comment https://forums.phpfreaks.com/topic/206146-everything-is-an-object/#findComment-1078593 Share on other sites More sharing options...
runeveryday Posted June 29, 2010 Author Share Posted June 29, 2010 That's exactly it. Objects can have methods and properties. Anything in javascript can have a method or a property attached to it (including functions, strings, or anything else). So everything is an object! yeah,Objects can have methods and properties. but if it is a variable, how to say it's an object ?eg var a='english'; Link to comment https://forums.phpfreaks.com/topic/206146-everything-is-an-object/#findComment-1078595 Share on other sites More sharing options...
trq Posted June 29, 2010 Share Posted June 29, 2010 Given your example, a is an object of type string. Everything is an object in Javascript, same as in Python, Ruby and probably a few other languages. Link to comment https://forums.phpfreaks.com/topic/206146-everything-is-an-object/#findComment-1078601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.