---
title: "string 扩展endWith"
author: "cai555"
date: "2009-04-03T17:45:13Z"
tags: ["JavaScript", "prototype"]
slug: "string-endwith"
draft: false
lastmod: "2009-04-03T17:45:13Z"
id: 361144
url: "https://cai555.iteye.com/blog/361144"
---

string 扩展endWith

 

```
<SCRIPT   LANGUAGE="JavaScript">  
  <!--  
  String.prototype.endWith=function(oString){  
  var   reg=new   RegExp(oString+"$");  
  return   reg.test(this);  
   
  }  
  alert("123".endWith("3"));  
  //-->  
  </SCRIPT>
```