aspx Tutorial

NET Articles,jQuery demo, with jQuery, online tutorial,Jquery, SilverLight, Javascript,,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here


Get our toolbar!


Posted by Aamir Hasan   on Wednesday, June 26, 2013 Total Views:  

In this example, we will see how to check undefined object property in JavaScript. When we will call a property in JavaScript without declaring, it will always give an error shown in below screen.


Let's, call a variable property and we will use typeof operator to check variable is not defined as shown below.

if (typeof aamir === "undefined") {

                alert("aamir object is undefined");




Here’s example



<head runat="server">


    <script type="text/javascript">

        function undefinedOP() {

            if (typeof aamir === "undefined") {

                alert("aamir object is undefined");



        function OPL() {

            var aamir = 'test';

            if (typeof aamir === "undefined") {

                alert("aamir object is undefined");

            } else {








    <form id="form1" runat="server">


            <input type="button" value="undefined object property" onclick="undefinedOP();"/>

            <input type="button" value="object property length" onclick="OPL();"/>









Click here to see demo

Category: All | | Javascript
Protected by Copyscape Online Plagiarism Tool

Comments (1) -

Fausto Grills
Fausto Grills United States
7/13/2015 8:26:41 AM #

Hmm it looks like your blog ate my first comment (it was extremely long) so I guess I'll just sum it up what I had written and say, I'm thoroughly enjoying your blog. I too am an aspiring blog blogger but I'm still new to the whole thing. Do you have any points for newbie blog writers? I'd certainly appreciate it.|

Add comment

  Country flag

  • Comment
  • Preview

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5