You are on page 1of 1

-

new

What happens when new is used with a function?


1 . creates a new object this : 3
Sets the objects inheritance be the
prototype to
prototype
2
property
.

of the
constructing function -

this .

proto-- ConstructingFunction prototype


3 if
. Checks the construction function returns anything other
than an object, away or
functions .
If so ,
the function
returns the newly constructe object .

4 .
returns this (the
newly constructed object) if there's
no return statement in the function body .

call
apply , ,

bind
·
use these to
explicitly set the value of this in

a
function .

·
use method of one object
a on another
·

prevents code duplication .

call
Function call -> set the this value
manually
fu .
call (param(
↑ pass in object that should
equal new this

fu call (obj Paraml


.

, ,

-
param 2)
L these Parameters
get passed to the function
after this is set to new
objects .

apply
·fr obi Fargl argeI)
.

apply , ,

-works the same as call except


pass awayin an of parameter as list

instead of
passing parameters one &
a time

You might also like