Prototype

935 views

Published on

Prototype Javascript

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
935
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Prototype

  1. 1. Module Prototype
  2. 2. Prototype <ul><li>The Prototype namespace provides fundamental information about the Prototype library, as well as the following information; </li></ul><ul><li>Version of Prototype </li></ul><ul><li>Browser features </li></ul><ul><li>Default iterators and functions </li></ul><ul><li>Moduleindex </li></ul>
  3. 3. Prototype <ul><li>K(argument) -> argument </li></ul><ul><li>K is Prototype’s very own identity function, i.e. it returns its argument untouched. </li></ul><ul><li>This is used throughout the framework, most notably in the Enumerable module as a default value for iterators </li></ul><ul><li>Examples; </li></ul><ul><li>1)Prototype.K( 'hello world!' ); </li></ul><ul><li>// -> 'hello world!‘ </li></ul><ul><li>2) Prototype.K( 1.5 ); </li></ul><ul><li>// -> 1.5 </li></ul><ul><li>3) Prototype.K(Prototype.K); </li></ul><ul><li>//-> Prototype.K </li></ul><ul><li>  </li></ul>
  4. 4. Prototype <ul><li>Prototype.Browser -> Object </li></ul><ul><li>Detects the current browser and returns an object </li></ul><ul><li>Possible Tests: </li></ul><ul><li>Prototype.Browser. IE </li></ul><ul><li>Prototype.Browser. Opera </li></ul><ul><li>Prototype.Browser. WebKit  // Safari </li></ul><ul><li>Prototype.Browser. Gecko </li></ul><ul><li>Example; </li></ul><ul><li>In case you are viewing in Mozilla: </li></ul><ul><li>Prototype.Browser </li></ul><ul><li>//-> Object: IE=false Opera=false WebKit=false Gecko=true </li></ul><ul><li>if (Prototype.Browser.Gecko) { </li></ul><ul><li>alert( &quot;It's a Gecko!&quot; )}   </li></ul><ul><li>  </li></ul>
  5. 5. Prototype <ul><li>emptyFunction([argument...]) </li></ul><ul><li>The emptyFunction does nothing… and returns nothing! </li></ul><ul><li>It is used thoughout the framework to provide a fallback function in order to cut down on </li></ul><ul><li>Example; </li></ul><ul><li>emptyFunction([argument...]) </li></ul><ul><li>The emptyFunction does nothing… and returns nothing! </li></ul>

×