{"id":583,"date":"2022-11-08T10:56:21","date_gmt":"2022-11-08T10:56:21","guid":{"rendered":"https:\/\/www.devopstrainer.in\/blog\/?p=583"},"modified":"2022-11-08T10:56:21","modified_gmt":"2022-11-08T10:56:21","slug":"what-is-alert-in-javascript","status":"publish","type":"post","link":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/","title":{"rendered":"What is alert() in javascript?"},"content":{"rendered":"\n<p>The\u00a0<strong>alert()<\/strong>\u00a0method in JavaScript is used to display a virtual alert box. It is mostly used to give a warning message to the users. It displays an alert dialog box that consists of some specified message (which is optional) and an OK button. When the dialog box pops up, we have to click &#8220;OK&#8221; to proceed.<\/p>\n\n\n\n<p>suppose a user is required to fill the form in which some mandatory fields are required to enter some text, but the user forgets to provide the input. we can use the alert dialog box to show a warning message related to fill the textfield.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/download.png\" alt=\"\" class=\"wp-image-585\" width=\"713\" height=\"409\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">syntax<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>alert(message)  <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">example<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html>\r\n&lt;html>\r\n&lt;head>\r\n\t\t&lt;title> alert in javascript&lt;\/title>\r\n&lt;\/head>\r\n&lt;body>\r\n\t\t&lt;script>\r\n\t\tvar q=12;\r\n\t\tvar r=23;\r\n\t\tif(q&lt;r)\r\n\t\t{\r\n\t\t alert(\"q is less then r\");\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t  alert(\"q is greater than r\");\r\n\t\t}\r\n\t\t&lt;\/script>\r\n\r\n&lt;\/body>\r\n&lt;\/html><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">output<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"516\" height=\"225\" src=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-110.png\" alt=\"\" class=\"wp-image-584\" srcset=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-110.png 516w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-110-300x131.png 300w\" sizes=\"auto, (max-width: 516px) 100vw, 516px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The\u00a0alert()\u00a0method in JavaScript is used to display a virtual alert box. It is mostly used to give a warning message to the users. It displays an alert&#8230; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-583","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is alert() in javascript? - DevOps | SRE | DevSecOps<\/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.devopstrainer.in\/blog\/what-is-alert-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is alert() in javascript? - DevOps | SRE | DevSecOps\" \/>\n<meta property=\"og:description\" content=\"The\u00a0alert()\u00a0method in JavaScript is used to display a virtual alert box. It is mostly used to give a warning message to the users. It displays an alert...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"DevOps | SRE | DevSecOps\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-08T10:56:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/download.png\" \/>\n<meta name=\"author\" content=\"shivam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"shivam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/\"},\"author\":{\"name\":\"shivam\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#\\\/schema\\\/person\\\/0c8259479972d3d18994f88df3dc8d53\"},\"headline\":\"What is alert() in javascript?\",\"datePublished\":\"2022-11-08T10:56:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/\"},\"wordCount\":110,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/download.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/\",\"url\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/\",\"name\":\"What is alert() in javascript? - DevOps | SRE | DevSecOps\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/download.png\",\"datePublished\":\"2022-11-08T10:56:21+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#\\\/schema\\\/person\\\/0c8259479972d3d18994f88df3dc8d53\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/download.png\",\"contentUrl\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/download.png\",\"width\":296,\"height\":170},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-is-alert-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is alert() in javascript?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/\",\"name\":\"DevOps | SRE | DevSecOps\",\"description\":\"Automation means Cost, Quality, Time\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#\\\/schema\\\/person\\\/0c8259479972d3d18994f88df3dc8d53\",\"name\":\"shivam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g\",\"caption\":\"shivam\"},\"url\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/author\\\/shivam\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is alert() in javascript? - DevOps | SRE | DevSecOps","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.devopstrainer.in\/blog\/what-is-alert-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"What is alert() in javascript? - DevOps | SRE | DevSecOps","og_description":"The\u00a0alert()\u00a0method in JavaScript is used to display a virtual alert box. It is mostly used to give a warning message to the users. It displays an alert...","og_url":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/","og_site_name":"DevOps | SRE | DevSecOps","article_published_time":"2022-11-08T10:56:21+00:00","og_image":[{"url":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/download.png","type":"","width":"","height":""}],"author":"shivam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"shivam","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/#article","isPartOf":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/"},"author":{"name":"shivam","@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53"},"headline":"What is alert() in javascript?","datePublished":"2022-11-08T10:56:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/"},"wordCount":110,"commentCount":0,"image":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/download.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/","url":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/","name":"What is alert() in javascript? - DevOps | SRE | DevSecOps","isPartOf":{"@id":"https:\/\/www.devopstrainer.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/#primaryimage"},"image":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/download.png","datePublished":"2022-11-08T10:56:21+00:00","author":{"@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53"},"breadcrumb":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/#primaryimage","url":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/download.png","contentUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/download.png","width":296,"height":170},{"@type":"BreadcrumbList","@id":"https:\/\/www.devopstrainer.in\/blog\/what-is-alert-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.devopstrainer.in\/blog\/"},{"@type":"ListItem","position":2,"name":"What is alert() in javascript?"}]},{"@type":"WebSite","@id":"https:\/\/www.devopstrainer.in\/blog\/#website","url":"https:\/\/www.devopstrainer.in\/blog\/","name":"DevOps | SRE | DevSecOps","description":"Automation means Cost, Quality, Time","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devopstrainer.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53","name":"shivam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g","caption":"shivam"},"url":"https:\/\/www.devopstrainer.in\/blog\/author\/shivam\/"}]}},"_links":{"self":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/comments?post=583"}],"version-history":[{"count":1,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/583\/revisions"}],"predecessor-version":[{"id":586,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/583\/revisions\/586"}],"wp:attachment":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/media?parent=583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/categories?post=583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/tags?post=583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}