Tag Archives: JavaScript Tutorial

Walkthrough for the null and undefined in JavaScript

In this article I will try to explain about the null and undefined in JavaScript. We will discuss the difference and uses of both.

Basically undefined is the type in the JavaScript. undefined value is returned when you use an object property that does not exist, or a variable that has been declared without assigning any value.It is not a reserved keyword so you can write a undefined as method or variable name. See the following code. Continue reading Walkthrough for the null and undefined in JavaScript

Check whether variable is defined or not in JavaScript

The only way to truly test if a variable is undefined is to do the following. Remember, undefined is an object in Javascript. To determine if a variable or object property exists, It is good to compare to keyword undefined or you can also check the type of the object to string ‘undefined’. Continue reading Check whether variable is defined or not in JavaScript

JavaScript Introduction

– JavaScript is an interpreted, object-based scripting language.

– JavaScript is the client side script(The script that is executed client-side, by the user’s web browser)

– JavaScript is a prototype-based scripting language(Prototype-based programming is a form of OOPS in which inheritance is performed through a process of cloning existing objects that serve as prototypes.) with dynamic typing.

– JavaScript is organized into statements, blocks consisting of related sets of statements.

– JavaScript also allows the comments like other programming languages.

Example

<!DOCTYPE html>
<html>
<head>
<script>
function CallFunction()
{
alert("Hello World!");
}
</script>
</head>
  <body>
    <button onclick="CallFunction()">Click  Here</button>
  </body>
 </html>

You can see the JavaScript code in the script code. When the user will click on the button ‘Click here’ the JavaScript code will be executed.

<script>
function CallFunction()
{
alert("Hello World!");
}
</script>

You can run the program by copy all code and paste in the text file and save with chapter1.html. After the save the file just open in any browser and click on the button.

In the next Chapter, we will start with the declaring variables and use the statements.