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. Quote 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(); Quote 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! Quote 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. Quote 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'; Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/206146-everything-is-an-object/#findComment-1078601 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.