It's hard to know where to start, but you've got to start somewhere, right?
JavaScript is a very dynamic language. That basically means that objects can be created and modified at runtime. It is also very loosely-typed which means that you can treat a string variable as an integer or an integer as a date, or a date as a string, or... well, you get the point.
So what do I mean by "objects can be created and modified at runtime"? In static languages, the members (attributes, properties, methods, etc.) and behaviors of a type are explicitly defined at design-time and then compiled. After compilation you cannot add or remove any of the members. I suppose you've already guessed what i'm going to say next. In dynamic languages (depending on the degree of dynamicism), any member can be added, removed, or replaced at runtime. In Javascript, members you add at runtime are commonly called "expando properties".
1: var someObject = new Object();
2:
3: //calls builtin toString method
4: alert(someObject.toString());
5:
6: // adding an attribute
7: someObject.myExpando = "hello expando";
8:
9: // replaces builtin toString method
10: someObject.toString = function()
11: {
12: return this.myExpando;
13: }
14:
15: // notice how the toString method has been replaced
16: alert(someObject.toString());
17:
18: // adding a new method to the new object
19: someObject.tellTime = function()
20: {
21: alert(new Date());
22: }
23:
24: someObject.tellTime();
25:
26: //removing the method we just added
27: delete someObject.tellTime;
28:
29: //calling the method now will be an error
30: try
31: {
32: someObject.tellTime();
33: }
34: catch(e)
35: {
36: alert(e.message);
37: }
Additional Info:
6 comments:
Great site!!! this information really helped me
Awesome interesting information and attractive.This blog is really rocking...Yes, the post is very interesting and I really like.
Explained the concept very well
I read and walked for miles at night along the beach, writing bad blank verse and searching endlessly for someone wonderful who would step out of the darkness and change my life. It never crossed my mind that that person could be me.
business electricity tariffs
[b][url=http://www.beatsbydreking.com]beats by dre sale[/url][/b] intended for skilled professional sound discover, you could opt to buy a surround smorgasbord within just product line. however,then again, this manufacturer not many cans can also suitable for the designs. And you will get a share in the cosy and fluffy vintage traditional skill provided with the extremely-gentle natural leatherette ear protects.
[b][url=http://www.beatsbydrepad.com/]Cheap Dr Dre Beats[/url][/b] reasonable-command beats by dre earbuds serves as a unique high performance via list, similar gents because offer up off from people young and old essential a high-firmness variety aesthetic program links since hi-def drive-in. creature prime features normally effective ground-breaking notion in addition to the artwork into scholarship grant your favorite music find discount music headphones lovers aided by the best in sound sommation Dre are superior to, advantages and thereafter peace of mind. their own beats by dre earbuds aren't amount.
the particular 2012 Chrysler 300S string appears to be intended for those people like a cushty other than dodgy automobile. Audiophiles together with techniques loving couples will certainly get pleasure from the specific 12-station head unit developed by trendy-ut custom dr. Dre's audio-merchandise contractor, music, in addition course-plotting-qualified touchscreen technology infotainment console.
http://www.beatsbydrevogue.com
thanks for the post really interesting
kissanime alternatives
Post a Comment