Simple Tutorial on Javascript console log Function | Coding Like a Pro
Simple Tutorial on Javascript console log Function

Simple Tutorial on Javascript console log Function

Who doesn’t know JavaScript? Probably a pundit on a sport show that has no desire for programming. But, in the programming world, we all start with JavaScript. And so, it’s not excusable if you are still battling to gain basic knowledge of JavaScript.

Anyways, to still refresh our memory, we will do a little explanation of this concept. As you may know, it is often abbreviated as JS. JavaScript is a superior, coherent programming language which suits the ECMAScript classification.

Did that sink? Well, that’s just a clue to what JavaScript is basically all about. If, indeed, your elementary knowledge of it is still shaky, you may a little more research online. However, this tutorial will move some miles ahead to discuss an advanced feature in JavaScript. If your knowledge in JavaScript isn’t well grounded, you may not catch up with this tutorial.

That said, this tutorial will be as simple and easy-to-follow as possible. So, whether you are a pro or a newbie, you can easily learn and apply the lesson.

What is Console.log()

As you already know, this lesson will focus on the Console.log function in Javascript. We will learn what it is and how we can apply it.

Please, note, as we progress in this lesson, we may substitute console with other synonyms like instrument panel or dashboard. This is to help us flow easily and avoid unnecessary repetition in the tutorial.

And before we progress, get this: Console.log() is understood as a Javascript function with which the programmer can reproduces whatever type of element that already exists in it. In another way, we may define it as that function that enables us print messages which we want displayed.

More About This Function

Having come this far in following this lesson, it’s obvious you are very keen to learning more. You want to follow the lesson to the end, especially the last part that will guide you on how to apply the tool, right? That’s great.

We aren’t just going to be discussing the concept. We’ll try our best to discuss the way to apply this toolinJavascript.

We won’t just rush it. We will take it slowly but steadily.

So, we are going to expand our knowledge of console.log(). Yes, we had previously defined it above. But, like we pointed out, there is much more about we need to discuss further.

Without any iota of doubt, you may have heard about the function, or know a thing or two about it; that is if you use the language for your programming. And if you are just starting out, don’t worry. You are going to get along pretty easy here, and the lesson will certainly put things right for you.

Overview of Console

Let’s get straight into the broader view of this instrument panel. You know, our browsers have internal enlargement instruments that work with web languages and Apps including JavaScript. Console is one of such inbuilt instruments or tools.

We can liken it to a shell interface. Why? Because, by default, it has instruments with which we can monitor the debug code, DOM, and then interpret network metrics.

More so, being one of the enlargement procedures of JavaScript, we can use console to register data. We can equally use it to interface with the framework of a web page. How we do this is to implement JavaScript statements within the framework of the page.

So, basically, we can say that console helps us script, run and track JavaScript based on demand.

Function of JavaScript console log

We have just learnt so much about this instrument panel. We certainly have been exposed to what it means and is all about.

Now, we’ll proceed the lesson by discussing the JavaScript’s assistance function known as console.log(). And just like we have stated above, with the use of console, we can debug code.

The log function registersthe assertion that’s given within the functions that we reproduce onto the console.

You may ask, what elements and information does function receive and print? Well, here it is:

[STRINGS, NUMBERS, ARRAYS, OBJECTS] etc. You can spend time to do practical exercises when we are done with the lesson. It’ll help you understand it better. 

The Best Way to Use Console Log in JavaScript

To understand this better, we have to take on some practical examples such as this:


Good, we’ve written that. So, what is the result? To show the result, we need to employ the Chrome browser. There is the F12 key in this browser. In other, for use to unlock the enlargement tools, we have to tap on this key. When that is done, we then proceed to the console tab.

We’ll take on another instance. But, in this second instance, we’ll offer 2 arguments to console.log(). While the primary argument is the print title, the secondary argument is the argument we proceed to print.

It goes as follows:

var red_color ='red';
var blue_color ='blue';
    console.log('first console statement:',red_color);
    console.log('second console statement:', blue_color);

So, can you tell what will happen next? You can give it a try. But, if you can’t, don’t bother yourself that much. We will get into it together. From the instance given, it is clear; the primary argument bears the name of the printed result, while the second is the result itself. Got it now? Great!

Console Statement

How Important is console log in JavaScript?

We’ve established our knowledge of the meaning and nature of this instrument panel. We equally learnt the console.log function i.e. how to apply it.

So, we can move on to discuss the importance of this feature to programmers and what it can do for us.

Let’s see them…

Debugging Code: you may be tempted to doubt the importance of this if you haven’t been using it or tried it out. It is very vital to every programmer that uses this programming language. You can easily find the point your code breaks through console.log.

Testing Purposes: so you know, this enables us to test the framework.

While we may just consider these two here, you may want to look up some others later on.

Wrap up

Now, we have come to the end. Certainly, you have learnt a lot on this topic. The tutorial equally did justice to the methods of using the framework.

And just like we had stated, this tool is highly important to every programmer who uses the JavaScript language. All you need do is to follow the practical example given in this lesson properly, and that’s it. Your problems are solved.

Nevertheless, for the purpose of expanding your knowledge, you may want to research further on the topic.

Spread the love
3 votes, average: 4.67 out of 53 votes, average: 4.67 out of 53 votes, average: 4.67 out of 53 votes, average: 4.67 out of 53 votes, average: 4.67 out of 5 (3 votes, average: 4.67 out of 5)
You need to be a registered member to rate this.

Leave a Reply