{"id":91760,"date":"2019-05-16T07:00:57","date_gmt":"2019-05-16T04:00:57","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=91760"},"modified":"2019-05-16T11:42:36","modified_gmt":"2019-05-16T08:42:36","slug":"javascript-generators-example","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html","title":{"rendered":"JavaScript Generators Example"},"content":{"rendered":"<p>Greetings readers! In this tutorial, we will explore the JavaScript Generators.<\/p>\n<h2>1. JavaScript Generators &#8211; Introduction<\/h2>\n<p><strong>JavaScript<\/strong> is an object-oriented programming language that allows the <em>client-side scripting<\/em> to interact with a user and deliver the dynamic pages. Most web browsers including Google Chrome, Mozilla Firefox, Safari, Internet Explorer, Microsoft Edge, Opera, etc. support it. The JavaScript scripting language includes:<\/p>\n<ul>\n<li>Declaring variables<\/li>\n<li>Maintaining the retrieving values<\/li>\n<li>Defining and invoking functions<\/li>\n<li>Defining classes<\/li>\n<li>Load and use external modules<\/li>\n<li>Define event handlers<\/li>\n<li>And much more \u2026.<\/li>\n<\/ul>\n<h3>1.1 Advantages of JavaScript Language<\/h3>\n<p>The pros of using the JavaScript scripting language are:<\/p>\n<ul>\n<li>JavaScript is easy to learn<\/li>\n<li>It executes on the client&#8217;s browser, so eliminates the server-side processing and be executed on any OS<\/li>\n<li>JavaScript can be used with any type of web page e.g. PHP, ASP.NET, Perl, etc<\/li>\n<li>Web-page performance increases due to client-side execution<\/li>\n<li>JavaScript code can be minified to decrease the loading time from the server<\/li>\n<li>Many JavaScript-based application frameworks are available in the market to create Single page web applications e.g. AngularJS, ReactJS, etc<\/li>\n<\/ul>\n<h3>1.2 Disadvantages of JavaScript Language<\/h3>\n<p>The cons of using the JavaScript scripting language are:<\/p>\n<ul>\n<li>Does not have any multi-threading or multi-processing capabilities<\/li>\n<li>Does not allow the file reading and writing capabilities<\/li>\n<\/ul>\n<h3>1.3 Closures in JavaScript<\/h3>\n<p>Closures in javascript are the inner functions that give access to the outer function\u2019s variables in addition to its own and global variables. In simple words, they are called inner functions. In this tutorial, we will create an anonymous function inside another anonymous function.<\/p>\n<h2>2. JavaScript Generators Example<\/h2>\n<p>Here is a systematic guide for implementing this tutorial.<\/p>\n<h3>2.1 Tools Used<\/h3>\n<p>We are using Eclipse Kepler SR2, JDK 8 and Maven. Having said that, we have tested the code against JDK 1.7, and it works well.<\/p>\n<h3>2.2 Project Structure<\/h3>\n<p>Firstly, let us review the final project structure if you are confused about where you should create the corresponding files or folder later!<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"323\" height=\"250\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-structure-guide-img-1.jpg\" alt=\"JavaScript Generators - Project Structure\" class=\"wp-image-91761\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-structure-guide-img-1.jpg 323w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-structure-guide-img-1-300x232.jpg 300w\" sizes=\"(max-width: 323px) 100vw, 323px\" \/><figcaption>Fig. 1: Application Project Structure<\/figcaption><\/figure>\n<\/div>\n<h3>2.3 Project Creation<\/h3>\n<p>This section will show how to create a Java-based Maven project with Eclipse. In Eclipse Ide, go to <code>File -&gt; New -&gt; Maven Project<\/code>.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"652\" height=\"605\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-1.jpg\" alt=\"JavaScript Generators - Maven Project\" class=\"wp-image-91813\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-1.jpg 652w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-1-300x278.jpg 300w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><figcaption>Fig. 2: Create a Maven Project<\/figcaption><\/figure>\n<\/div>\n<p>In the New Maven Project window, it will ask you to select the project location. By default, &#8216;Use default workspace location&#8217; will be selected. Just click on the next button to proceed.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"599\" height=\"545\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-2.jpg\" alt=\"JavaScript Generators - Project Details\" class=\"wp-image-91814\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-2.jpg 599w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-2-300x273.jpg 300w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><figcaption>Fig. 3: Project Details<\/figcaption><\/figure>\n<\/div>\n<p>Select the &#8216;Maven Web App&#8217; Archetype from the list of options and click next.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"598\" height=\"541\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-3.jpg\" alt=\"JavaScript Generators -  Archetype Parameters\" class=\"wp-image-91815\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-3.jpg 598w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/springboot-hibernate-project-guide-3-300x271.jpg 300w\" sizes=\"(max-width: 598px) 100vw, 598px\" \/><figcaption>Fig. 5: Archetype Parameters<\/figcaption><\/figure>\n<\/div>\n<p>It will ask you to &#8216;Enter the group and the artifact id for the project&#8217;. We will input the details as shown in the below image. The version number will be by default: <code>0.0.1-SNAPSHOT<\/code>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"524\" height=\"490\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-guide-img-4.jpg\" alt=\"JavaScript Generators - Archetype Parameters\" class=\"wp-image-91765\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-guide-img-4.jpg 524w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-guide-img-4-300x281.jpg 300w\" sizes=\"(max-width: 524px) 100vw, 524px\" \/><figcaption>Fig. 5: Archetype Parameters<\/figcaption><\/figure>\n<\/div>\n<p>Click on Finish and the creation of a maven project is completed. If you see, it has downloaded the maven dependencies and a <code>pom.xml<\/code> file will be created. It will have the following code:<\/p>\n<p><span style=\"text-decoration: underline\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n\t&lt;groupId&gt;wcg.tutorial&lt;\/groupId&gt;\n\t&lt;artifactId&gt;Javascriptclosures&lt;\/artifactId&gt;\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n\t&lt;packaging&gt;war&lt;\/packaging&gt;\n&lt;\/project&gt;\n<\/pre>\n<h2>3. Application Building<\/h2>\n<p>Let us see the sample code snippet to understand the <em>closures<\/em> in the javascript language.<\/p>\n<p><span style=\"text-decoration: underline\"><em>index.jsp<\/em><\/span><\/p>\n<pre class=\"brush: html; wrap-lines:false;\">&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/loose.dtd\"&gt;\n&lt;html&gt;\n\n&lt;head&gt;\n    &lt;title&gt;Index Page&lt;\/title&gt;\n    &lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=ISO-8859-1\"&gt;\n    &lt;link rel=\"stylesheet\" href=\"https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.7\/css\/bootstrap.min.css\"&gt;\n    &lt;script type=\"text\/javascript\"&gt;\n    \t\/\/ Javascript function.\n        var incrementClickCount = (function() {\n            var clickCount = 0;\n            return function() {\n                return ++clickCount;\n            }\n        })();\n    &lt;\/script&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n    &lt;div class=\"container\"&gt;\n        &lt;h2 align=\"center\" class=\"text-primary\"&gt;JavaScript Closures Example&lt;\/h2&gt;\n        &lt;hr \/&gt;\n        &lt;!------ JavaScript Closures Example ------&gt;\n        &lt;div class=\"form-group\"&gt;\n            &lt;!-- button. --&gt;\n            &lt;button type=\"button\" class=\"btn btn-primary\" onclick=\"alert(incrementClickCount());\"&gt;Click me&lt;\/button&gt;\n        &lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;\n\n&lt;\/html&gt;\n<\/pre>\n<h2>4. Run the Application<\/h2>\n<p>As we are ready for all the changes, let us compile the project and deploy the application on the Tomcat7 server. To deploy the application on Tomat7, right-click on the project and navigate to <code>Run as -&gt; Run on Server<\/code>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"591\" height=\"403\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-deploy-guide-img-1.jpg\" alt=\"JavaScript Generators - Deploy Application on Tomcat\" class=\"wp-image-91766\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-deploy-guide-img-1.jpg 591w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-deploy-guide-img-1-300x205.jpg 300w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><figcaption>Fig. 6: How to Deploy Application on Tomcat<\/figcaption><\/figure>\n<\/div>\n<p>Tomcat will deploy the application in its web-apps folder and shall start its execution to deploy the project so that we can go ahead and test it in the browser.<\/p>\n<h2>5. Project Demo<\/h2>\n<p>Open your favorite browser and hit the following URL to display the application\u2019s index page and console output as shown in Fig. 7.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">http:\/\/localhost:8082\/Javascriptclosures\/<\/pre>\n<p>Server name (localhost) and port (8082) may vary as per your Tomcat configuration.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"639\" height=\"133\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-demo-guide-img-1.jpg\" alt=\"JavaScript Generators - Index page\" class=\"wp-image-91767\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-demo-guide-img-1.jpg 639w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/project-js-closures-demo-guide-img-1-300x62.jpg 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><figcaption>Fig. 7: Index page<\/figcaption><\/figure>\n<\/div>\n<h2>6. Conclusion<\/h2>\n<p>In this section, developers learned how to create a simple application with the JavaScript language. Developers can download the sample application as an Eclipse project in the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>7. Download the Eclipse Project<\/h2>\n<p>This was a beginner\u2019s tutorial to explore the JavaScript Generators.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/Javascriptarraymethodstutorial.zip\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>JavaScript Generators Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Greetings readers! In this tutorial, we will explore the JavaScript Generators. 1. JavaScript Generators &#8211; Introduction JavaScript is an object-oriented programming language that allows the client-side scripting to interact with a user and deliver the dynamic pages. Most web browsers including Google Chrome, Mozilla Firefox, Safari, Internet Explorer, Microsoft Edge, Opera, etc. support it. The &hellip;<\/p>\n","protected":false},"author":26931,"featured_media":20900,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1879],"tags":[803],"class_list":["post-91760","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript Generators Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about JavaScript? Then check out our detailed example on JavaScript Generators!\" \/>\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.javacodegeeks.com\/2019\/05\/javascript-generators-example.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Generators Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about JavaScript? Then check out our detailed example on JavaScript Generators!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-16T04:00:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-16T08:42:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin Batra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin Batra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html\"},\"author\":{\"name\":\"Yatin Batra\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\"},\"headline\":\"JavaScript Generators Example\",\"datePublished\":\"2019-05-16T04:00:57+00:00\",\"dateModified\":\"2019-05-16T08:42:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html\"},\"wordCount\":662,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"keywords\":[\"JavaScript\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html\",\"name\":\"JavaScript Generators Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"datePublished\":\"2019-05-16T04:00:57+00:00\",\"dateModified\":\"2019-05-16T08:42:36+00:00\",\"description\":\"Interested to learn more about JavaScript? Then check out our detailed example on JavaScript Generators!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/01\\\/javascript-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/javascript-generators-example.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"JavaScript Generators Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\",\"name\":\"Yatin Batra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"caption\":\"Yatin Batra\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\\\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\\\/\\\/www.javacodegeeks.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yatin-batra\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Generators Example - Java Code Geeks","description":"Interested to learn more about JavaScript? Then check out our detailed example on JavaScript Generators!","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.javacodegeeks.com\/2019\/05\/javascript-generators-example.html","og_locale":"en_US","og_type":"article","og_title":"JavaScript Generators Example - Java Code Geeks","og_description":"Interested to learn more about JavaScript? Then check out our detailed example on JavaScript Generators!","og_url":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-05-16T04:00:57+00:00","article_modified_time":"2019-05-16T08:42:36+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","type":"image\/jpeg"}],"author":"Yatin Batra","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin Batra","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html"},"author":{"name":"Yatin Batra","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d"},"headline":"JavaScript Generators Example","datePublished":"2019-05-16T04:00:57+00:00","dateModified":"2019-05-16T08:42:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html"},"wordCount":662,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","keywords":["JavaScript"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html","url":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html","name":"JavaScript Generators Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","datePublished":"2019-05-16T04:00:57+00:00","dateModified":"2019-05-16T08:42:36+00:00","description":"Interested to learn more about JavaScript? Then check out our detailed example on JavaScript Generators!","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/01\/javascript-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/javascript-generators-example.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/www.javacodegeeks.com\/category\/web-development"},{"@type":"ListItem","position":3,"name":"JavaScript","item":"https:\/\/www.javacodegeeks.com\/category\/web-development\/javascript"},{"@type":"ListItem","position":4,"name":"JavaScript Generators Example"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d","name":"Yatin Batra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","caption":"Yatin Batra"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/yatin-batra"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/91760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/26931"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=91760"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/91760\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/20900"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=91760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=91760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=91760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}