Javascript Simple Actions

Sometimes for writing a javascript you need to have some views about your model (variable) and any other things. Some developers use javascript "Alert(..)" and "console.log()" functions .

Here are some examples using alert or console log.

Alert() function

<!DOCTYPE html>
<html>
  <body>
    <h2>Here is Alert function example</h2>
    <button type="button" onclick="action()">Click Me!</button>
    <script>
      function action() {
         alert("Hello I'm alert");
      }
    </script>
  </body>
</html>

Using Alert function we can show string, number, array and if we want to show any object, the alert shows us only its type.

Example of Alert

<!DOCTYPE html>
<html>
  <body>
    <h2>Here is Alert function example</h2>
    <button type="button" onclick="action()">Click Me!</button>
    <script>
      function action() {
         var obj = {name: 'Arame',age: 35}
         alert(obj);
      }
    </script>
  </body>
</html>

More interesting and good method is console.

Javascript Console

Console has some properties, which let us have better code and nicer application.

Console has

  • Console.log(...)
  • Console.error(...)
  • Console.warn(...)
  • Console.info(...)
  • Console.assert(...)
  • etc..

Console helps you to read your code, know where and what happens and tell you the way you want .

More interesting thing is JCD (Javascript Code Debuging)

JCD (Javascript Code Debuging)

You will never become javascript developer, if you don't know what is JCD and how to make JCD.

JCD (Javascript Code Debuging) supports all web browsers and every browser has its way of making it.

Debuging the javascript code means to follow running your application, checking out what's happening , when it is happening and more important Why it is happening. It's more professional to understand your code and still another important thing, that Debuging helps you to have less bugs and less problems. You can minimize your problems and clean your logic code.