Console utilities.log()

Asked

Viewed 1,745 times

8

I was doing a refactoring on a code made in the format MVC, making the code more readable, eliminating duplicated code and deleting variables and API’s that were no longer being used.

When deleting some "console.log(algo.aqui)", I was asked why to eliminate them, I promptly replied that it was something that one of the thousands of programmers who had already moved there had forgotten after checking and validating some value in the console.

He informed me that console.log() is not something only used to validate the value of a variable, which also has its applications in both the front end and the back end of the application.

While researching not found much.

So I’d like to know:

  • What are the uses of console.log() in the front-end
  • What are the uses of console.log() in the back-end?
  • What are the effects that lead to its use? What does it differ from simply passing the variable?
  • 3

    It’s weird to be negative without comment, especially since I haven’t broken any rules of inquiry. I genuinely want to know, even if it’s an answer like: no, there’s no other function for it.

  • 3

    Also I did not understand why negative, maybe neither the person who negative understand pq. kkk

  • @abfurlan removed the negative

  • 1

    It would not be duplicated:https://answall.com/questions/38057/o-que-%C3%A9-console-log . And I was not the one who denied =D

5 answers

9


console.log will call the method log of the console object.

Congratulations Captain Obvious, this information changed my life!

Calm down, young man. It turns out that the implementation of the console object is different in each environment.

It is quiet to say that, in the most normal case, the console involved is that of the browser. But depending on your environment, this object can write data in different places. Your application can run in a development or testing environment, rather than the browser. In such cases, the console in which the data will be written will be that of this tool.

Backend: the console can be an external window. While the application is running, the administrator can get an idea of what happens underneath the scenes. This is useful for those working with Javascript on the server (see Node.js).

  • 3

    I was waiting for someone to quote the nodejs rs +1

4

Good afternoon

As the folks said above used basically as a Debugger of your code, but I’ll give an example where the console log.() helps a lot, currently working with frameworks like Angular and Vue.js, with these frameworks we create several layers in our frontend (Controller, Service, Factory, etc) with the console.log() we can analyze the state of the data that are being trafficked between the layers, this is important because we can see where and when the data is being processed and changed.

Remember that the console object also has other methods, such as:

  • console error.()
  • console info.()
  • console debug.()
  • console profile.()

See you around.

3

It is a Javascript resource used for debugging (debugging).

It generates logs that can be consulted in the browser console.

In Google Chrome, press CTRL+SHIFT+I, choose "console". This is where the logs will be printed.

Each browser has a specific console. Note that browsers in older versions do not support this feature.

Usefulness in the backend? That I know is null as it is a frontend resource between Javascript and Browser.

What are the effects that lead to its use? What does it differ from simply pass the variable?

It has nothing to compare with "passing variables" because they are very different things. It is merely an aid feature for debugging scripts. In the old days we had to use the alert() which became a problem in an infinite loop dropped by mistake, for example, because the browser maintained the alert() infinitely. Moreover it is silent and can even leave it active in production environment, as long as it does not compromise safety.

The utility in keeping active is that it facilitates even in customer support. A customer who complains that they can’t navigate a page, you can ask the customer to printscreen the console log. This helps very especially when the client is layman and can not say right what is going on.

One thing you should be careful about is that browsers have the resources to keep a log history. If saving sensitive data logs is a serious security risk as a malicious person with access to the victim’s computer can easily view the console logs.

1

Hello Expensive use enough Javascript, today the console.log for me has the function to validate if some routines are working as they should. Example have an application does various calculations to sell products and whenever a calculation is made it gives a log with console.log information containing how the calculation was done. And this information is sent to an archive for future analysis.

I do not know if it would be a usability of the console.log, but it is say.

0

Console.log is only used to debug information on brownsers (Firefox with Firebug, Chrome, IE8).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.