user1464139
user1464139

Reputation:

Variable showing as both having a value and as being undefined in Chrome debugger?

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 !

Upvotes: 2

Views: 414

Answers (1)

Alexander Gessler
Alexander Gessler

Reputation: 46607

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.

Upvotes: 1

Related Questions