{"id":7776,"date":"2023-07-20T13:03:46","date_gmt":"2023-07-20T07:33:46","guid":{"rendered":"https:\/\/innovationm.co\/?p=7776"},"modified":"2023-07-20T13:03:46","modified_gmt":"2023-07-20T07:33:46","slug":"temporal-dead-zone","status":"publish","type":"post","link":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/","title":{"rendered":"Temporal Dead Zone"},"content":{"rendered":"<p>A temporal dead zone (TDZ) is the area of a block where a variable is inaccessible until the moment the computer completely initializes it with a value. A block is a pair of braces ( {&#8230;} ) used to group multiple statements.<\/p>\n<p>The temporal Dead Zone is the period of time during which the let and const declarations cannot be accessed.<\/p>\n<p>The Temporal Dead Zone starts when the code execution enters the block which contains the let or const declaration and continues until the declaration has been executed.<\/p>\n<p>Temporal Dead Zone Basically work on let and const not work on var<\/p>\n<p>let and const does not hoist they are held in a scope called TDZ<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-7778\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/07\/Screenshot-175-300x169.png\" alt=\"\" width=\"350\" height=\"197\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Screenshot-175-300x169.png 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Screenshot-175-768x433.png 768w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Screenshot-175-624x352.png 624w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Screenshot-175.png 970w\" sizes=\"(max-width: 350px) 100vw, 350px\" \/><\/p>\n<p>The temporal Dead Zone is the period of time during which the let and const declarations cannot be accessed.<\/p>\n<p>The temporal Dead Zone starts when the code execution enters the block which contains the let or const declaration and continues until the declaration has been executed.<\/p>\n<p>In our code example above, Temporal Dead Zone starts after the opening parenthesis of the printAge function and continues until after the declaration of the age variable.<\/p>\n<p>Consider the following code example that illustrates an interesting point about the Temporal Dead Zone.<\/p>\n<p>The final salient difference between let \/ const and var is that if you access var before it&#8217;s declared, it is undefined. But if you do the same for let and const, they throw a ReferenceError.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-7777\" src=\"https:\/\/innovationm.co\/wp-content\/uploads\/2023\/07\/Screenshot-176-300x127.png\" alt=\"\" width=\"364\" height=\"154\" srcset=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Screenshot-176-300x127.png 300w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Screenshot-176-768x325.png 768w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Screenshot-176-624x264.png 624w, https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Screenshot-176.png 980w\" sizes=\"(max-width: 364px) 100vw, 364px\" \/><\/p>\n<p>Therefore, a let (or const) variable\u2019s TDZ ends when JavaScript fully initializes it with the value specified during its declaration.<\/p>\n<p>However, a var variable\u2019s TDZ ends immediately after its hoisting\u2014not when the variable gets fully initialized with the value specified during its declaration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A temporal dead zone (TDZ) is the area of a block where a variable is inaccessible until the moment the computer completely initializes it with a value. A block is a pair of braces ( {&#8230;} ) used to group multiple statements. The temporal Dead Zone is the period of time during which the let [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7779,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[256,360,71,585,570,258],"tags":[722,770,888,765,889],"class_list":["post-7776","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-application","category-javascript","category-mobile","category-mobile-app-development","category-software-testing","category-web-technology","tag-blog","tag-bloggers","tag-tdz","tag-technology","tag-temporal-dead-zone"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Temporal Dead Zone - InnovationM - Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Temporal Dead Zone - InnovationM - Blog\" \/>\n<meta property=\"og:description\" content=\"A temporal dead zone (TDZ) is the area of a block where a variable is inaccessible until the moment the computer completely initializes it with a value. A block is a pair of braces ( {&#8230;} ) used to group multiple statements. The temporal Dead Zone is the period of time during which the let [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/\" \/>\n<meta property=\"og:site_name\" content=\"InnovationM - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-20T07:33:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Temporal-Dead-Zone.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1689\" \/>\n\t<meta property=\"og:image:height\" content=\"950\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InnovationM Admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InnovationM Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/\"},\"author\":{\"name\":\"InnovationM Admin\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"headline\":\"Temporal Dead Zone\",\"datePublished\":\"2023-07-20T07:33:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/\"},\"wordCount\":285,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Temporal-Dead-Zone.png\",\"keywords\":[\"blog\",\"bloggers\",\"TDZ\",\"technology\",\"Temporal dead zone\"],\"articleSection\":[\"Java Application\",\"JavaScript\",\"Mobile\",\"Mobile App Development\",\"Software Testing\",\"Web Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/\",\"name\":\"Temporal Dead Zone - InnovationM - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Temporal-Dead-Zone.png\",\"datePublished\":\"2023-07-20T07:33:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Temporal-Dead-Zone.png\",\"contentUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/Temporal-Dead-Zone.png\",\"width\":1689,\"height\":950},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/temporal-dead-zone\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Temporal Dead Zone\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\",\"name\":\"InnovationM - Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\",\"name\":\"InnovationM Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"caption\":\"InnovationM Admin\"},\"sameAs\":[\"http:\\\/\\\/www.innovationm.com\\\/\"],\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/author\\\/innovationmadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Temporal Dead Zone - InnovationM - Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/","og_locale":"en_US","og_type":"article","og_title":"Temporal Dead Zone - InnovationM - Blog","og_description":"A temporal dead zone (TDZ) is the area of a block where a variable is inaccessible until the moment the computer completely initializes it with a value. A block is a pair of braces ( {&#8230;} ) used to group multiple statements. The temporal Dead Zone is the period of time during which the let [&hellip;]","og_url":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/","og_site_name":"InnovationM - Blog","article_published_time":"2023-07-20T07:33:46+00:00","og_image":[{"width":1689,"height":950,"url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Temporal-Dead-Zone.png","type":"image\/png"}],"author":"InnovationM Admin","twitter_misc":{"Written by":"InnovationM Admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/#article","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/"},"author":{"name":"InnovationM Admin","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"headline":"Temporal Dead Zone","datePublished":"2023-07-20T07:33:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/"},"wordCount":285,"commentCount":0,"image":{"@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Temporal-Dead-Zone.png","keywords":["blog","bloggers","TDZ","technology","Temporal dead zone"],"articleSection":["Java Application","JavaScript","Mobile","Mobile App Development","Software Testing","Web Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/","url":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/","name":"Temporal Dead Zone - InnovationM - Blog","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/#primaryimage"},"image":{"@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Temporal-Dead-Zone.png","datePublished":"2023-07-20T07:33:46+00:00","author":{"@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"breadcrumb":{"@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/#primaryimage","url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Temporal-Dead-Zone.png","contentUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2023\/07\/Temporal-Dead-Zone.png","width":1689,"height":950},{"@type":"BreadcrumbList","@id":"https:\/\/www.innovationm.com\/blog\/temporal-dead-zone\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.innovationm.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Temporal Dead Zone"}]},{"@type":"WebSite","@id":"https:\/\/www.innovationm.com\/blog\/#website","url":"https:\/\/www.innovationm.com\/blog\/","name":"InnovationM - Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.innovationm.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed","name":"InnovationM Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","caption":"InnovationM Admin"},"sameAs":["http:\/\/www.innovationm.com\/"],"url":"https:\/\/www.innovationm.com\/blog\/author\/innovationmadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/7776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/comments?post=7776"}],"version-history":[{"count":0,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/7776\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media\/7779"}],"wp:attachment":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media?parent=7776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/categories?post=7776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/tags?post=7776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}