JavaScript学習ノート018-オブジェクト向けプログラミング思考0コンストラクション関数0 Class

2095 ワード

Author:Mr.柳上原
  • いかなる努力にも劣らない努力を払う
  • 私たちのすべての努力が、生活に裏切られないことを願っています.
  • 初心を忘れないで、ずっと
  • を得なければなりません.
    勉強は終わりがないですね.
    htmlとcssを勉強しました.
    cssとJavaScriptの勉強が終わりました
    jsとjQueryの勉強が終わりました
    jqを学んでH 5がまだあります
    H 5とcss 3を勉強しました
    css 3とNodejsを勉強しました
    nodeとVuejsを学んだ
    Vueを学んだ後、採用履歴書にcssの前処理Sass、Less、Stylusがあることに気づいた.
    そしてBootstrap
    そしてReact+Redux
    Angularも
    そして・・・
     
    
     
    
     
    
     
    
    
    
    
    
    
    
      59      
    
     
    
    
    
    
    
     
    
    
    /*
      :  
    
            :
         
      
      
    cup
    ......
    
            :
                
      :    》   
                 
       :       ,         
    
            :
      
      
      
    */
    //           
    function Person(opt){
    //        
    this.name = opt.name;
    this.age = opt.age;
    this.sex = opt.sex;
    
    //        
    // prototype   (  )
    Person.prototype = {
    eat(value){ },
    run(value){ },
    }
    return obj;
    }
    // Person   
    const p1 = Person(name: "  ", age: 18, sex: " ");
    const p2 = Person(name: "  ", age: 26, sex: " ");
    
    /*
        :
    new   ( );
    
                :
    1.new         
    2.    this    
    3.     
    
    new   ( );
      ( );
    */
    //            
    let a = "123"; //    
    let b = new String(123); //     
    
    //     
    function fn(){
    console.log(this);
    }
    fn( ); // this  window
    new fn( ); // this  fn{ }  
    let c = fn( ); // undefined
    let d = new fn( ); // fn{ }
    
    /*
    Class:
     es6      , es6      (     )
         
     let const  ,       ,      
    */
    // es5  
    function Person1(name, age){
    //     
    this.name = name;
    this.age = age;
    }
    Person1.prototype = {
    //     
    add (){},
    sub (){},
    }
    const obj1 = new Person1("fengyu", 18);
    
    // es6  
    Class Person2{
    //     
    constructor (name, age){
    this.name = name;
    this.age = age;
    }
    // constructor           
    add (){}
    sub (){}
    }
    const obj2 = new Person2("fengyun", 27);