JavaScript learning Summary

Source: Internet
Author: User

Objective:
1. Web-related development is becoming increasingly popular, and it is necessary to learn JS.

2. Learn one more language and want to learn more about the cultural connotation of one language.

3. Get to know the scripting language. I have been learning C, C ++ for a taste.

 


Learning path:
1. Project accumulation during previous internships

2. various pieces of information on the Internet

3. codecademy's online Js teaching courses (lengthy and meticulous courses, typing and hand cramps)

4. Various books, such as headfirst Js

 


Sporadic feelings: (I have been adding)

1. Attributes of classes in js can be identified by. Or ["xx "].


2. JS also has encapsulation. In the class constructor, var is used to define attributes or methods instead of this


3. The Function Definition of Js is not well divided, but the variable definition is followed by a semicolon.


4. this in functions and classes cannot be omitted.


5. Js instantiation is implemented through the new constructor.

Function Person (name, age ){

[Javascript]
This. name = name;
This. age = age;
}
// Let's make bob and susan again, using our constructor
Var bob = new Person ("Bob Smith", 30 );

This. name = name;
This. age = age;
}
// Let's make bob and susan again, using our constructor
Var bob = new Person ("Bob Smith", 30); 6. Use prototype to enable this attribute for each instance and implement inheritance
[Javascript]
// The original Animal class and sayName method
Function Animal (name, numLegs ){
This. name = name;
This. numLegs = numLegs;
}
Animal. prototype. sayName = function (){
Console. log ("Hi my name is" + this. name );
};
 
// Define a Penguin class
Function Penguin (name, numLegs ){
This. name = name;
This. numLegs = 2;
}
 
// Set its prototype to be a new instance of Animal
Penguin. prototype = new Animal ();
 
Var penguin = new Penguin ("Gigi ");
Penguin. sayName ();

// The original Animal class and sayName method
Function Animal (name, numLegs ){
This. name = name;
This. numLegs = numLegs;
}
Animal. prototype. sayName = function (){
Console. log ("Hi my name is" + this. name );
};

// Define a Penguin class
Function Penguin (name, numLegs ){
This. name = name;
This. numLegs = 2;
}

// Set its prototype to be a new instance of Animal
Penguin. prototype = new Animal ();

Var penguin = new Penguin ("Gigi ");
Penguin. sayName ();

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.