+ Start a Discussion
Ankit SaxenaAnkit Saxena 

Clarity with Console.log

Hello...
I have written up my console statment in javascript controller as 
                console.log('return' +response.getReturnValue());
1. Not sure, if this is correct or not. If not, then what is the correct step. ?
2. Its giving log as below where i cant see 'return' text in not present in the log though it return the 5 records i am expecting. Am i missing something?
User-added image
Raj VakatiRaj Vakati
See My comments ..   
console.log('return' +response.getReturnValue()) --- > This statement is correct you can use event differnt ways 
1. Not sure, if this is correct or not. If not, then what is the correct step. ? -- Statment is correct and you can use as below also to print as JSON
console.log( JSON.stringify(response.getReturnValue(), null, "    ") );


2. Its giving log as below where i cant see 'return' text in not present in the log though it return the 5 records i am expecting. Am i missing something?

Console.log will print the value to the browser and its same like System.debug and not required any return statement to print the value 

 
Akhil ReddyAkhil Reddy
@Ankit Saxena

1. It looks good to me.
2. This is strage, I tried with same script for console log but it returned with string in console. May be the Returnvalue structure is differnent in your case I see

 
Ankit SaxenaAnkit Saxena
@raj - What i meant to say---
if you write as system.debug('return:'+return); and if value of return is 5; so it will be displayed as return:5. 'return' keyword will be there in debug log. 
but as you can see here, there is no 'return' keyword but only output. so my question was why ? Did i missed out anything?
Ankit SaxenaAnkit Saxena
@akhil - what did you tried in console log ? can you publish here. My expectation is as - 
if you write as system.debug('return:'+return); and if value of return is 5; so it will be displayed as return:5. 'return' keyword will be there in debug log. 
but as you can see here, there is no 'return' keyword but only output.