JavaScript-- seven (inherited)

One,

The way this type of student that person, write like this though inherited, but the parent class is to inherit property in the prototype student

In order to change the type of student he would need to add a "student.constructor = student"

Since this method to inherit the prototype, so if we can only pass parameters when they could pass new parameters, namely student.prototype = new person (and there may write)

You object name = new student (and there can not write parameters)

Therefore, this method has many limitations, so we rarely use

two,

person.call: Borrowing Constructor

This method can be mass participation, but this kind of method can not be inherited

three,

This method is invoked who is who

function:

The following slow implementation, to parse twice

Function is the object

Function declaration:

The second call fun () prints out undefined, because he is the assignment will increase

This looks all right

this:

apply:

apply this first parameter is the object pointed to

The second is an array

The first call and apply, as his second pass is a direct reference

When calling the first item in the array parameter in the first position, followed by recursive

Compare Max:

Delite obj.0 can not be written because the variable name can not start with a number

Use object masquerading quick removal

Note that we define a pseudo-array

Function as a parameter:

You can adjust the sort order sort

Return value as a function of:

Closure:

 

Guess you like

Origin www.cnblogs.com/kongbursi-2292702937/p/10798636.html