js原型链实例

<!DOCTYPE HTML>
<html>
    <head>
        <title>please enter your title</title>
        <meta charset="utf-8">
        <meta name="Author" content="年轻人">
        <style type='text/css'> *{ margin:0; padding:0;} </style>
    </head>
    <body>

        <script type="text/javascript"> function Person( name , age ){ this.name = name; this.age = age; } Person.prototype.marry = true; Person.prototype.showName = function(){ alert( this.name ); return this; } Person.prototype.showAge = function(){ alert( this.age ); return this; } var p1 = new Person('excel' , '35'); var p2 = new Person('逗逼丫‭丫' , '20'); var p3 = new Person('拖鞋' , '28'); p3.showName().showAge(); </script>
    </body>
</html>

你可能感兴趣的:(JavaScript,prototype,实例)