<!DOCTYPE html>
<html>
<head>
<title>Prototype Pattern Example</title>
<script type="text/javascript">
alert(typeof Array.prototype.sort); //"function"
alert(typeof String.prototype.substring); //"function"
String.prototype.startsWith = function (text) {
return this.indexOf(text) == 0;
};
var msg = "Hello world!";
alert(msg.startsWith("Hello")); //true
</script>
</head>
<body>
</body>
</html>
qq_T_T
turboburst
相关分类