0
Why dose it give me [object object]
function e(p) { console.log(p); p = 5; console.log(p); } https://code.sololearn.com/Wd0SWquGDNJR/?ref=app
6 Antworten
+ 1
Your function doesn't output anything as it is never called.
Can you please check what exactly you did when you got that output?
+ 1
Anthony Johnson There is no need to declare p because p is a parameter of the function.
+ 1
Lisa Anthony Johnson thanks!
0
The reason is because you tried to log the value of p before its value was declared.
0
ODLNT Yes if there is a parameter given, but declaring p = 5 after passing in the value of p is pointless. A beter practice would be.
function e(p) {
this.p = p;
console.log(this.p);
console.log(this.p + 5);
}
e(5);
//first output 5
//second output 10