Objects in Javascript
The whole JavaScript engine is based on objects. Objects forms the core functionality of the JavaScript. Every variable defined in JavaScript automatically takes form of object depending upon the value passed to it. Thought Objects is a concept of Object Oriented Programming but JavaScript does not implement Pure Object Oriented Programming Approach.
Every Object has methods and properties associated with it. Properties defines the values associated with the object. Method defines the action that needs to be performed on the object.
Example - Using Properties
<script type="text/javascript"> var txt="Hello World!" document.write(txt.length) </script>
Explanation: Here .length defines the properties where it will return the number of character the txt variable holds.
Just a small intro to document.write for those who are unaware of this in JavaScript. Basically it does the operation of showing the content on the screen.
Example - Using document.write
<script type="text/javascript"> document.write("Hello World"); </script>
Explanation: The above example will print “Hello World” on the screen.
Example - Using Methods in Objects
<script type="text/javascript"> var str="Hello world!" document.write(str.toUpperCase()) </script>
Explanation: Here .toUpperCase() is the methods associated with the str variable.
Similar Posts
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.


Objects in Javascript…
[...]The whole JavaScript engine is based on objects. Objects forms the core functionality of the JavaScript. Every variable defined in JavaScript automatically takes form of object depending upon the value passed to it. Thought Objects is a concept of…