JSOO의 이해

3735 단어 대상을 향하다
<script type="text/javascript">

    ///<summary>
    /// Animal 
    ///</summary>
    function Animal(name) {
        // 
        this.Name = name;
        

        //public  
        this.Shout = function () {
            alert(" Animal,  " + this.Name);
        };

        //private  
        var _Shout = function () {
            alert("private _Shout");
        };
    };
    ///<summary>
    /// Cat 
    ///</summary>
    function Cat() {
        this.Catch = function () {
            alert(" Cat, ");
        };
        //Cat Shout
        //this.Shout = function () {
        //    alert(" Cat, ~");
        //};
    };
    Cat.prototype = new Animal(); //Cat  Animal

    // 
    window.onload = function () {
        var a1 = new Animal();
        a1.Name = " a1";
        a1.Shout();
        // 
        var a2 = new Animal(" a2");
        a2.Shout();

        var c1 = new Cat();
        c1.Name = " c1";
        c1.Catch();
        c1.Shout();

    };
    
</script>

좋은 웹페이지 즐겨찾기