JavaScript objects and functions
-
Upload
victor-verhaagen -
Category
Documents
-
view
346 -
download
1
description
Transcript of JavaScript objects and functions
JAVASCRIPTOBJECTS & FUNCTIONSVictor Perez
/ INTRODUCTION
⁄ ⁄ ⁄
● string, number, boolean, null and undefined
● Wrapper objects: String, Number and Boolean
● Object, Function, Boolean, Error, EvalError, RangeError, ReferenceError, SyntaxError,
TypeError, URIError, Number, Math, Date, String, RegExp, Array and JSON
● Host objects
● no class inheritance
● prototype inheritance
OBJECTSINTRODUCING
⁄ ⁄ ⁄
● Objects
● Function scope
● this and arguments
● constructor
● prototype
● return ( default: undefined )
FUNCTIONSINTRODUCING
/ OBJECTS
⁄ ⁄ ⁄
● literal
● constructor
● Object.create
CREATEOBJECTS
⁄ ⁄ ⁄
● Object.constructor
CONSTRUCTOROBJECTS
/ PROTOTYPE
⁄ ⁄ ⁄
● Inheritance
● Any object
● Prototype chain
● Read inheritance
● Write own property
INTRODUCTIONPROTOTYPE
⁄ ⁄ ⁄
EXAMPLEPROTOTYPE
⁄ ⁄ ⁄
EXAMPLEPROTOTYPE
⁄ ⁄ ⁄
● Object.create
PROTOTYPEOBJECTS
⁄ ⁄ ⁄
● Object constructor
PROTOTYPEOBJECTS
/ FUNCTIONS
⁄ ⁄ ⁄
● function statement
STATEMENTFUNCTIONS
⁄ ⁄ ⁄
● function expression
● The name is only available inside the
function
EXPRESSIONFUNCTIONS
⁄ ⁄ ⁄
● Function constructor
○ eval
○ global scope
CONSTRUCTORFUNCTIONS
/ THIS
⁄ ⁄ ⁄
GLOBAL CONTEXTTHIS
● Global object
● window in the browser
⁄ ⁄ ⁄
FUNCTION CONTEXTTHIS
● non strict
○ Global object
● strict mode
○ undefined
⁄ ⁄ ⁄
OBJECT METHODTHIS
● Object of the method
⁄ ⁄ ⁄
CONSTRUCTORTHIS
● Object of the new created object
⁄ ⁄ ⁄
CALL & APPLYTHIS
● First parameter will be bound to this
● call
● apply
● convert it to an object
⁄ ⁄ ⁄
BINDTHIS
● returns the same function where this is the same as the first parameter
● this can’t be changed
/ JAVASCRIPT
/ QUESTIONS?
THANKS