Questions tagged [console.log]

a debugging tool for JavaScript. It is method of the console object which logs the given object in the Browser's JS console.

log method of the console object is a method mainly used for debugging purposes.

Syntax

console.log(obj1 [, obj2, ..., objN]);

Parameters

obj1...objN - A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output.

Example

Here is a simple JavaScript example which illustrates the use of console.log:

var foo = {'id':7, 'name':'John Doe'};
console.log(foo);

Output (in the console) - {id:7, name:"John Doe"}.

Note - The result my vary depending upon the browser's implementation of console.

Browser Compatibility

This feature is fully-supported on the latest versions of all the major browsers.

  • Mozilla Firefox 4+
  • Microsoft Internet Explorer 8+ (only after opening the F12 developer tools)
  • Google Chrome 1+
  • Opera 10.50+
  • Apple Safari 3+
2040 questions
22
votes
3 answers

Nodejs on Azure where is output of the console log

I deployed a nodejs web app on azure as an App Service How do i see the console.log from my application?
developer7788
  • 389
  • 1
  • 2
  • 15
22
votes
3 answers

Webpack console.log output?

Can anyone direct me in the right direction? So i've setup the webpack-dev-server with the truffle suite demo, just to get a basis on the foundation of my app. So my config file includes index.html & app.js, yet it try to display a console.log…
22
votes
5 answers

console.log(!status) in global scope producing unexpected result

Ran into an interesting issue. I was working on trying to toggle a boolean that was assigned to a variable. It wasn't working and eventually I tried this code. var status = false; console.log(!status); I expected it to provide true in the…
FrontEnder
  • 251
  • 2
  • 9
22
votes
4 answers

Avoid the detection of "whether Chrome DevTools(console) is open"

Today I see this post Find out whether Chrome console is open . @zswang gave the way to detect if Chrome DevTools(console) is open. That's really suprise me, then I began to think is there any way to walk around this detection technique? There are…
Mithril
  • 12,947
  • 18
  • 102
  • 153
22
votes
4 answers

Firebug console: not showing console.log

I am trying to test something, and for one reason or another, while working in the Firebug console, I am unable to create an array of script tags on the HTML page using the getElementByTagName('script') method. I realize there is probably something…
beckah
  • 1,543
  • 6
  • 28
  • 61
20
votes
3 answers

Python print vs Javascript console.log()

In Python: print [1,2], '\n', [3,4] would print [1,2] [3,4] In Javascript: console.log([1,2],'\n',[3,4]) prints [1,2] '\n' [3,4] What is the equivalent Javascript statement to the above Python print?
Shinto C V
  • 714
  • 1
  • 9
  • 16
20
votes
2 answers

Console.log a multi-dimensional array

So I have created a multi-dimensional array: (i.e. one with two sets of 'coordinates') var items = [[1,2],[3,4],[5,6]]; My site is in development and the array, when it is loaded, and what it contains is constantly changing, so I need to be able…
19
votes
3 answers

How can truncated console.log output in Firefox Version 57 be extended?

The recent Version 57 release of the Firefox browser truncates output when console.log(variable) is used in Javascript to write the content of a variable to the F12 developer tools console. If the value in the variable is long (such as when printing…
wurzel_gummidge
  • 287
  • 2
  • 11
19
votes
6 answers

Show original order of object properties in console.log

I need for some debugging to see the original order of one JavaScript object's properties but (at least in chrome devtools) console.log() shows me an alphabetically ordered object. Ex: var obj = { z: 1, t: 2, y: 3, a: 4, n: 5, …
MTK
  • 3,300
  • 2
  • 33
  • 49
18
votes
5 answers

Showing all output in the console VS code

I am using console.log in my javascript program in VS code to output to the console a lot of values. When I print a few values to the console using console.log, I am able to see every value in the console window as normal. But when there are a lot…
Obama nation
  • 191
  • 1
  • 1
  • 6
18
votes
3 answers

How do you send console messages and errors to alert?

I would like to pass errors to an alert to warn the user they made mistake in their code even if they don't have console open. var doc=(frame.contentWindow.document || obj.contentDocument|| obj.contentWindow); var head =…
Jenita
  • 291
  • 1
  • 3
  • 15
17
votes
7 answers

VueJS 2: How To Remove Console.log from Production Builds?

In IE, console is only defined when in F12 debugging mode. So I'm looking for a convenient way to manage the compilation of Vue I'd like to be able to write console.log inside the code alert('a'); console.log('only in development…
Janka
  • 1,908
  • 5
  • 20
  • 41
17
votes
6 answers

Capture browser console logs with capybara

I need to capture the console logs (category: info) of a browser using Ruby & Capybara. Until now I have tried using driver.manage.logs.get(:browser) or (:client) but, using this, the result is not what I want. It gives out the interaction results…
Vivek Khurana
  • 251
  • 1
  • 3
  • 8
17
votes
4 answers

Add dynamic values to the console methods at run-time with preservation of original call position and line number intact

I made the following class to 'hijack' the console.log function. The reason behind this is that I want to add and remove values dynamically. It will be used for debug purposes, so the origin of the function call console.log() is important. In the…
17
votes
8 answers

Uncaught TypeError: Vue.component is not a function

In OS X with Laravel/Homestead, I'm getting an error using Vue (v2.2.1). The component won't load and the console error is "Uncaught TypeError: Vue.component is not a function". Full console error Uncaught TypeError: Vue.component is not a…
Stephen Pappas
  • 173
  • 1
  • 1
  • 5