Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

This Part 3: Direct Assignment

This Part 3: Direct Assignement
by

joe trece

on 29 May 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of This Part 3: Direct Assignment

How 'this' Gets its Value:
Way 3: Direct Assignment JavaScript's 'this' keyword gets set in four main ways. Only 1 of these ways allows direct assignment to 'this' Some of those methods are Array methods, like 'filter()' [ ] someArray.filter(someFunction, thisArgument) {
... this ...
} 'thisArgument' becomes 'this'
in someFunction() Other methods, like 'call()', let you specify 'this' for any function anyFunction. call( thisArgument, ...) {
... this ...
} 'thisArgument' becomes 'this'
in anyFunction() The following example shows how the filter() method lets you assign values to 'this' You're shopping for a new house. Since you just won the lottery, you're only considering houses priced over $1 million. We can represent your criteria with the following JavaScript code. myHouseCriteria = {

} minimumPrice:1000000 And here's a list of houses for sale. var houses = [ {price:123456}, {price:1234567}, {price:12345} ] Now apply your criteria to filter out unwanted houses. shortList = houses.filter(pickOutGoodHouses, myHouseCriteria ) The filter() method calls the function pickOutGoodHouses() for each house in the houses array. [ ] Here's the result: one house priced over $1 million. [ {price:1234567} ]
Full transcript