JavaScript undefined Property Last Updated : 08 Feb, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The undefined property is used to check if a value is assigned to a variable or not. Syntax: var x; if (typeof x === "undefined") { txt = "x is undefined"; } else { txt = "x is defined"; } Return Value: It returns 'defined' if the variable is assigned any value and 'undefined' if the variable is not assigned any value. More example code for the above property are as follows: Below are examples of the undefined Property. Example 1: JavaScript var a ="Geeksforgeeks" function test() { if (typeof a === "undefined") { txt = "'a' is undefined"; } else { txt = "'a' is defined"; } console.log(txt); } test(); Output: 'a' is defined Example 2: HTML <body> <center> <h1 style="color: green"> GeeksforGeeks </h1> <button onclick="test()"> Press </button> <h4> Click on the Press button to check if "a" is defined or undefined. </h4> <p id="gfg"></p> <script> function test() { if (typeof a === "undefined") { txt = "'a' is undefined"; } else { txt = "'a' is defined"; } document.getElementById( "gfg").innerHTML = txt; } </script> </center> </body> Output: Supported Browsers: Google ChromeFirefoxInternet ExplorerOperaSafari Comment More infoAdvertise with us Next Article JavaScript Object Properties R riarawal99 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Properties Similar Reads Undefined in JavaScript Undefined is a type of Data type in JavaScript. It is a primitive value undefined, when a variable is declared and not initialized or not assigned with any value. By default, the variable was stored with an Undefined value. Undefined is a global read-only variable that represents the value Undefined 2 min read JavaScript String prototype Property The prototype property allows to add new properties and methods to the existing JavaScript object types. There are two examples to describe the JavaScript String prototype property. Syntax: object.prototype.name = valueReturn Value: It returns a reference to the String.prototype object.Example 1: Th 2 min read Undefined Vs Null in JavaScript In JavaScript, both undefined and null represent the absence of a meaningful value, but they have different purposes and are used in distinct contexts. Knowing when and how to use each can help you write clearer, more predictable code. Let's see the differences between undefined and null in JavaScri 4 min read JavaScript Object Properties JavaScript objects are collections of properties, where each property is defined as a key-value pair. Understanding object properties is important to working with JavaScript as they enable dynamic storage, access, and manipulation of data.Defining Object PropertiesYou can create objects using object 3 min read JavaScript Symbol unscopables Property The Symbol.unscopables property in Javascript is a well-known symbol that is used to specify an object value of whose own and inherited property names are excluded from the environment bindings. Syntax: object[Symbol.unscopables] Property attributes: This property holds an Object and it is not Writ 2 min read How to Detect an Undefined Object Property in JavaScript ? Detecting an undefined object property is the process of determining whether an object contains a certain property, and if it does, whether the value of that property is undefined. This is an important concept in JavaScript programming, as it helps to prevent errors that can occur when attempting to 3 min read Like