so, i'm a rookie and i have a simple js file to print several string without any loop. i run it by vscode Code Runner extension. and the output just looping my program over and over until nodejs turn it off.
here is my code and errormessage, thx my code error message
i've test another simple file by Code Runner and it just go well
i'm wondering is there some setting i do wrong or just Code Runner extension is broken?
You are calling fun()
from inside fun()
. This is recursion, and causing an infinite loop.
For next time, please post code and errors as text surrounded in three backticks (```), not images.
Here is the correct code:
function fun(z) {
console.log(`we have a argument named z`)
console.log(`print by call the argumentName: ${z}`)
console.log(`print by call the argument.length: ${arguments.length}`)
console.log(`print by call the this.length: ${this.length}`)
console.log(`print by call the functionName.length: ${fun.length}`)
// This line is calling `fun()` from inside `fun()`, causing an infinite loop.
// console.log(`print by call the functionName().length: ${fun().length}`)
}
let a = 5
fun(a);