Thread: prototype
View Single Post
  #1 (permalink)  
Old November 6th, 2011, 04:23 PM
irProject irProject is offline
Friend of Wrox
Points: 742, Level: 10
Points: 742, Level: 10 Points: 742, Level: 10 Points: 742, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2009
Location: Tehran, Iran
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default prototype

Hello,

I've found extreme extensibility in javascript. one of these items is prototype.
the first example:

Code:
String.prototype.endsWith = function(str){
   return (this.substring(this.length - str.length, str.length) == str);
}

if('hello'.endsWith('lo')){
    alert('OK!');
}

var x = 'this is one sample';
if(x.endsWith('ple')){
   alert('second use');
}
Reply With Quote