Before learning a period of time JS, and now look, feel like a new knowledge, explain their grasp of JS is not very good (is very bad, never better, hey), here, in the review
If you eldest brother elder sister unfortunate see,, the forehead this is only own notes.
The idea of object-oriented in JS is absolutely important, if you look at the code of the Great God, you will know how important the idea of object-oriented in JS is.
Everything in JavaScript is an object: A string, a number, an array (array), a date, and so on.
In JavaScript, objects are data that owns properties and methods.
Properties and Methods
1, the property is the value associated with the object. 2. The method is an action that can be performed on the object.
For example, a car is a real-life object.
Properties of the car:
car.name = Fiat Car.model = car.weight = 850kg car.color = White
Method of Car:
car.start () car.drive () car.brake ()
in JavaScript, objects are data (variables) that have properties and methods. when declaring a JavaScript variable:
var txt = new String ("Hello World");
Over hereThe String object has built-in properties and methods:txt.length (property) Txt.indexof ("World") (method)
Creating JavaScript Objects (1)person=new Object ();
person.firstname= "John";
person.lastname= "Doe";
person.age=50;
person.eyecolor= "Blue";(2)
person={firstname: "John", LastName: "Doe", Age:50,eyecolor: "Blue"};
(3) using the Object Builder
function Person (firstname,lastname,age,eyecolor) { this.firstname=firstname; This.lastname=lastname; This.age=age; This.eyecolor=eyecolor; }
Learn JavaScript notes 1 JavaScript objects 1