PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are developing an HTML5 web application that displays customer mailing address information.
The application loads addresses from a web service by using AJAX. The following code defines a
Customer object and loads address data.

You need to implement the loadAddress function.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

6 Comments on “Which code segment should you use?

  1. nazish ali says:

    I think C,D both should be added in the answer list, because the only difference is “this” is assigned into “that” variable, so “D” should also be the correct one.




    0



    0
  2. Mahaha Meeee says:

    @nazish you are assuming that this doesn’t change, it does. “this” changes dynamically according to the context, that doesn’t. So set this to that and then change the context which changes this to something else, but you still have the old this because you set it to that.




    0



    0
    1. Terminator says:

      Answer C: Uncaught TypeError: this.parseAdress is not a function.
      IN C this refers to jquery get function:

      Object
      accepts
      :
      Object
      async
      :
      true
      contentType
      :
      “application/x-www-form-urlencoded; charset=UTF-8”
      contents
      :
      Object
      converters
      :
      Object
      crossDomain
      :
      false
      dataTypes
      :
      Array[2]
      flatOptions
      :
      Object
      global
      :
      etc. all AJAX options..




      0



      0
  3. VladimirV says:

    The answer is right. If you use answer D ‘this’ will point to the jQuery get function and not the Customer object. In answer C ‘this’ point to Object{firstName:””, lastName:””, address:””}




    0



    0

Leave a Reply