this
this
is a property of an execution context.
new
keyword is used when calling the function, this
inside the function is a brand new object.apply
, call
, or bind
are used to call/create a function, this
inside the function is the object that is passed in as the argument.obj.method()
- this
is the object that the function is a property of.this
is the global object. In a browser, it is the window
object. If in strict mode, this
will be undefined
instead of the global object.this
value.null
, undefined
, undeclaredvar
, let
or const
.undefined
is a variable that has been declared, but not assigned a value.null
will have been explicitly assigned to the null
value. It represents no value and is different from undefined
in the sense that it has been explicitly assigned.function getFee(isMember) {
return (isMember ? '$2.00' : '$10.00');
}
console.log(getFee(true));
// Expected output: "$2.00"
console.log(getFee(false));
// Expected output: "$10.00"
console.log(getFee(null));
// Expected output: "$10.00"
A statement used to enable strict mode to entire scripts or individual functions.
this
is undefined in the global context.function.caller
and function.arguments
.