console.log

console.log() called on object other than console

我的未来我决定 提交于 2019-12-21 03:09:15
问题 I remember that always when I wanted to pass console.log as a callback parameter to some function, it didn't work unless I used the bind() method to bind console to it. For example: const callWithTest = callback => callback('test'); callWithTest(console.log); // That didn't use to work. callWithTest(console.log.bind(console)); // That worked (and works) fine. See Uncaught TypeError: Illegal invocation in javascript. However, recently I noticed that console.log() works fine even when called on

Dumping whole array: console.log and console.dir output “… NUM more items]”

妖精的绣舞 提交于 2019-12-20 10:32:07
问题 I am trying to log a long array so I can copy it quickly in my terminal. However, if I try and log the array it looks like: ['item', 'item', >>more items<<< ... 399 more items ] How can I log the entire array so I can copy it really quickly? 回答1: Setting maxArrayLength There are a few methods all of which require setting maxArrayLength which otherwise defaults to 100. Provide the override as an option to console.log or console.dir console.log( myArry, {'maxArrayLength': null} ); Set util

for loop works fine with console.log but not innerHTML?

别说谁变了你拦得住时间么 提交于 2019-12-20 05:15:19
问题 hello i'm very new to javascript so forgive me if the answer seems obvious... this is my code which is executed at the click of a button in the body function q() { var A = document.getElementById("time_one").value; var B = document.getElementById("time_two").value; var C = document.getElementById("post_number").value; var D = (B - A) / C; for ( var x = A; x < B; x = x + D ) { document.getElementById("q_box").innerHTML = x + "<br />"; } } i'm pretty sure the error is in the for loop... the

Node.js - console.log does not show items in array but instead shows [Object]

纵饮孤独 提交于 2019-12-20 03:19:44
问题 I have a problem with logging out the contents of an array inside an object. The actual object looks like this var stuff = { accepted: [ 'item1', 'item2' ], rejected: [], response: 'Foo', envelope: { from: 'The sender', to: ['new item1', 'new item2'] }, messageId: 'xxxxxxxxxxxxx' } } The console.log shows the items of the first array fine but the second array is being output as [Object] . { accepted: [ 'item1', 'item2' ], rejected: [], response: 'Foo', envelope: { from: 'The sender', to:

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

浪尽此生 提交于 2019-12-18 12:49:15
问题 This question already has answers here : Boolean variable returns as string from javascript function (2 answers) Closed 3 years ago . 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 console, but instead I got false . I figured that javascript would run the code inside the parenthesis first to find it's

console.log browser in android emulator

时间秒杀一切 提交于 2019-12-18 10:52:08
问题 How to see console.log messages of a website using android emulator? 回答1: From Rich Chetwynd's short article "Javascript debugging on Android browser". You can log javascript errors and console messages from your Android device or emulator. To do this you first need to install the Android SDK and USB drivers and enable USB debugging on the actual device. To check if the device is connected correctly you can run the following cmd from your Android SDK tools directory and you should see a

Show original order of object properties in console.log

假装没事ソ 提交于 2019-12-17 20:35:09
问题 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, k: 6 } console.log(obj) shows this: Object {z: 1, t: 2, y: 3, a: 4, n: 5…} a:4 k:6 n:5 t:2 y:3 z:1 //expected (needed ) original order z: 1 t: 2 y: 3 a: 4 n: 5 k: 6 回答1: console.log does indeed sort the properties, in some cases you can use JSON.stringify which

Why does console.log say undefined, and then the correct value? [duplicate]

こ雲淡風輕ζ 提交于 2019-12-17 16:12:31
问题 This question already has answers here : Chrome/Firefox console.log always appends a line saying undefined (6 answers) Closed 5 years ago . console.log("hi") gives undefined hi console.log(1+1) gives undefined 2 Whether it's a string or integer calculation, I get undefined then the correct answer. Why do I get the undefined message? Is there a good way to avoid it? 回答1: The console will print the result of evaluating an expression. The result of evaluating console.log() is undefined since

Print console.log on HTML [duplicate]

时光怂恿深爱的人放手 提交于 2019-12-14 03:37:00
问题 This question already has answers here : Display javascript variable in html body (4 answers) Closed 2 years ago . I've a javascript code that is currently working on a shared hosting. The script gather data from a website and then show it on my website. Fact is that the data is being showed in the console tab but not on the php page. The script itself contains that code: <script> ... function printFollowers(followersSum) { console.log(followersSum); // you can do print followersSum wherever

React Remote Console Logging

ぐ巨炮叔叔 提交于 2019-12-14 01:09:28
问题 I setup an Express Server with Mongo to record console logs during debug testing of an Electron app using React. I simply use ajax to send what I would normally print with console.log. This works fine with individual events I want logged, but how do I export the entire chrome style console as an object so that anything that would reach the console (example: webpack messages, messages from other components etc) would all be accessible as one object that I can do a POST on. Basically a way to