2

I have this Typescript function:

retrieve = () => { var url = "/api/Exam/Retrieve/" + this.configService.admin.examStatusId + "/" + this.configService.admin.examTypeId + "/" + this.userService.data.subjectId; this.home.retrieve(url) } 

When I break on this line this.home.retrieve(url) and hover over examStatusId and examTypeId and subjectId I see the values 1,1 and 1.

When I hover over url I see "/api/Exam/Retrieve/undefined/undefined/1"

Here's my console output:

console.log(this.configService.admin.examStatusId) 1 undefined console.log(url) /api/Exam/Retrieve/undefined/undefined/1 undefined 

Can someone explain why on the second line I see "1" and then below that "undefined" when doing a console.log and why the url has undefined?

Problem solved:

My Typescript had not compiled to Javascript correctly. I was debugging the Typescript but behind it was the old javascript !

3
  • 1
    I don't know what language the first code sample is in, but it's not JavaScript. Commented Aug 28, 2014 at 5:44
  • 2
    It is ES6 function shorthand: ariya.ofilabs.com/2013/02/es6-and-arrow-function.html Commented Aug 28, 2014 at 5:46
  • Sorry I was not clear. It's Typescript. Commented Aug 28, 2014 at 5:53

1 Answer 1

1

The second line is the return value of the console.log function, printed by the console for your convenience (and undefined because no value is returned). The first line is the actual output of console.log.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Do you have any idea why the url might be showing undefineds ?
Okay problem solved. My Typescript had not compiled to Javascript correctly after I made some changes. Thanks for the answer about the value returned.