Hi friends,
I am sure many of us have troubles differentiating between these two. Well not to fear , in the coming days i will share some info that will shed light on both these two things, which will help us in understanding which is what.
But first, let me give a simple example of both of them to clear doubts about these two from the mind of us, who are still new bees.
NORMAL JAVASCRIPT :
I know, many of you know how to write normal java script.
For those who are unaware of this , it is written in your html in this way :
Your normal script-tag goes here where you call your function , let us assume you do this in this way :
(button) onclick = callfunction();
//Then add your function :
callfunction()
{
//Do your operation
}
OOPS JAVASCRIPT :
Now the structural flow of a oops java script is very similar to your normal flow of a java program.
Here you have a class and its objects.
There is a syntactical difference also with normal javascript :
Your normal script-tag goes here where you call your function , let us assume you do this in this way :
(button) onclick = callfunction();
//your function call syntax will be a little different here :
callfunction : function()
{
//Do your operation
}
Hence you see the function is added as:
functionName : function(your parameters)
{
}
This is the end of article 1.
Be sure to visit my blog later so that you can see article 2 in detail and other interesting tips and techniques .
As far as I understand, this is only a part of the bigger picture...
ReplyDeleteWhat you have demonstrated is another JSON-ish style of declaring functions...
Would help immensely if you gave a complete class as example.
Yes, you are quite right.
DeleteThat's why i said a detailed picture will be coming on the next article .