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 an 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>
A more interesting and good method is the console.
Javascript Console
The console has some properties, which let us have better code and nicer applications.
Console has
- Console.log(...)
- Console.error(...)
- Console.warn(...)
- Console.info(...)
- Console.assert(...)
- etc..
The console helps you to read your code, know where and what happens, and tell you the way you want.
The more interesting thing is JCD (Javascript Code Debugging)
JCD (Javascript Code Debugging)
You will never become a javascript developer if you don't know what is JCD and how to make JCD.
JCD (Javascript Code Debugging) supports all web browsers, and every browser has its way of making it.
Debugging the javascript code means following 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 Debugging helps you to have fewer bugs and fewer problems. You can minimize your problems and clean your logic code.
0 Comments
CAN FEEDBACK
Emoji