What does ".then" mean in JavaScript?

Discussion in 'JavaScript' started by xarzu, Feb 22, 2018.

  1. #1
    What does ".then" mean in JavaScript?

    Consider this snippet of code:


    return ajaxService.request('post', 'api/{ticketId}/alt-forms/getSatelliteMapUrl', geoCodedata, { failureMessage: 'Failed to Geocode SatMap/PDF'})
    .then(function (satelliteMapData, data) {


    Is the ".then" comment attached immediately to the previous "return" statement? If so, how? If not, then would the functionality of this JavaScript bit not be impacted if I put an "alert" statement immediately before the ".then" statement and immediately after the "return" statement?
     
    xarzu, Feb 22, 2018 IP
  2. Blizzardofozz

    Blizzardofozz Well-Known Member

    Messages:
    132
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    118
    #2
    I suggest you read more about the promise in JavaScript.
     
    Blizzardofozz, Feb 24, 2018 IP
  3. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #3
    ccoonen, Feb 26, 2018 IP
  4. wco

    wco Well-Known Member

    Messages:
    145
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    165
    #4
    its a then, you should do the math and realize how PEMDAS works or something similar, so you can monitor your codes better, and not lose time.
     
    wco, Mar 8, 2018 IP