最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to remove "debugger eval code" at the end of the output in console - Stack Overflow

programmeradmin1浏览0评论

I'm using Firefox 66.0.3.

When I execute the following snippet

[1,1,5,76,7,8,8,85,8,5,85,5,5,55].forEach(x => console.log(x))

or whatever code that has console.log() the browser shows debugger eval code at the end of the line in the output.

How to remove "debugger eval code" from output?

I'm using Firefox 66.0.3.

When I execute the following snippet

[1,1,5,76,7,8,8,85,8,5,85,5,5,55].forEach(x => console.log(x))

or whatever code that has console.log() the browser shows debugger eval code at the end of the line in the output.

How to remove "debugger eval code" from output?

Share Improve this question edited Sep 4, 2022 at 7:22 marc_s 757k184 gold badges1.4k silver badges1.5k bronze badges asked Apr 24, 2019 at 7:57 mihkovmihkov 1,19916 silver badges39 bronze badges 4
  • 3 I have to ask... why does it matter? – freefaller Commented Apr 24, 2019 at 7:58
  • I want to copy the whole output, without this debugger eval code – mihkov Commented Apr 24, 2019 at 8:26
  • 1 That's just the way the console works, the right side shows where every log message es from. – Barmar Commented Apr 24, 2019 at 8:45
  • Is there a setting to remove that ? – mihkov Commented Apr 24, 2019 at 10:32
Add a ment  | 

3 Answers 3

Reset to default 3

Unfortunately there is no way (at this date) to disable that but there is a way for solving your problem

Define an array with one "\n" element:

temp = ["\n"]

Add each of your message with "\n" at end to array

temp.push(message+"\n")

Then log the array with spread operator

console.log(...temp)

now you log your whole messages with just ONE eval code

you can now easily select all the log without eval code because of first "\n" element

Join your list with line breaks:

console.log([1,1,5,76,7,8,8,85,8,5,85,5,5,55].join('\n'))

You can then safely copy the result without the debugger eval code strings.

I ran across this when trying to scrape some data I didn't want to try to copy and paste due to the other garbage that would have e with the data I wanted, so I will presume your case is similar.

If so, just use window.alert() instead of console.log() to prevent the extra characters.

The new code would bee:

 window.alert([1,1,5,76,7,8,8,85,8,5,85,5,5,55])

or

collection = [1,1,5,76,7,8,8,85,8,5,85,5,5,55]; window.alert(collection);
发布评论

评论列表(0)

  1. 暂无评论