<html>
    <head>
        <script>
            function Point(x,y){
                this.x=x;
                this.y=y;
            }
            var p=new Point(1,2);
            console.log(p.x);
            console.log(p.y);

            Point.prototype.r=function(){
                return Math.sqrt(this.x*this.x+
                this.y*this.y);
            };

            //window.print(p.r());
            document.write(p.r());
        </script>
    </head>
    <body>
        <div>
            I am a good girl
        </div>
    </body>
</html>

 

posted on 2018-03-07 08:34  王洪洪  阅读(178)  评论(0编辑  收藏  举报