<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prabu Subra</title>
    <description>The latest articles on DEV Community by Prabu Subra (@prabusubra).</description>
    <link>https://dev.to/prabusubra</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F32451%2F210f2956-1275-4e3e-932f-6eac8afbf53e.jpg</url>
      <title>DEV Community: Prabu Subra</title>
      <link>https://dev.to/prabusubra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prabusubra"/>
    <language>en</language>
    <item>
      <title>Spring Beans Lifecycle</title>
      <dc:creator>Prabu Subra</dc:creator>
      <pubDate>Sat, 26 Nov 2022 19:20:11 +0000</pubDate>
      <link>https://dev.to/prabusubra/spring-beans-lifecycle-ogb</link>
      <guid>https://dev.to/prabusubra/spring-beans-lifecycle-ogb</guid>
      <description>&lt;p&gt;Spring IoC container create the beans and perform few post process activities based on the configurations like implementing Aware interfaces and annotations.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yZQvJd9x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ts6o1qntomdqd0tm5kka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yZQvJd9x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ts6o1qntomdqd0tm5kka.png" alt="Spring Bean Lifecycle" width="880" height="746"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a nutshell, Spring IoC Container first check for dependency then calls its constructor. After creation of bean, it first injects the dependencies auto wired 0n constructor, Field and setters. Then Aware interfaces(BeanNameAware, BeanClassLoaderAware, ApplicationContextAware…) and annotated method like PostConstruct is invoked. At last init-method is invoked.&lt;/p&gt;

&lt;p&gt;Main Method:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Solution1 {
 public static void main(String[] args) {
  AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SolutionConfig.class);
  Post post1 = context.getBean(Post.class);
  context.close();
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configuration file:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Configuration
public class SolutionConfig {

 @Bean
 public Author author() {
  return new Author("Aplha, Engineer", "alphaengineer@gmail.com");
 }

 @Bean
 public Post post() {
  return new Post("Spring Bean Lifecycle hooks", author());
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Post class:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Getter
@Setter
@NoArgsConstructor
public class Post {

 private UUID id;
 private String content;
 private Author author;

 @Autowired
 public Post(String content, Author author) {
  System.out.println(" Author from Post constructor : "+author.toString());
  this.id = UUID.randomUUID();
  this.content = content;
  this.author = author;
 }
 public void setAuthor(Author author) {
  System.out.println(" setAuthor : "+author.toString());
  this.author = author;
 }
 @Override
 public String toString() {
  return "Post [id=" + id + ", content=" + content + ", author=" + author.toString() + "]";
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Author Class:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Getter
@Setter
@NoArgsConstructor
public class Author {

 private UUID id;
 private String fullName;
 private String email;

 public Author(String fullName, String email) {
  System.out.println("Author constructor");
  this.id = UUID.randomUUID();
  this.fullName = fullName;
  this.email = email;
 }

 @Override
 public String toString() {
  return "Author [id=" + id + ", fullName=" + fullName + ", email=" + email + "]";
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample Output:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Author constructor
Author from Post constructor : Author [id=0b6afb4d-02d8-4f17-adfd-57aeafb8f206, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]
Post : Post [id=4d5e403f-a75b-43f0-bf8f-d596a0e5814d, content=Spring Bean Lifecycle hooks, author=Author [id=0b6afb4d-02d8-4f17-adfd-57aeafb8f206, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dependencies are instantiated and injected based on Auto wiring configuration. if we use setter auto wiring then respective setter will called and add dependency.&lt;/p&gt;

&lt;p&gt;Configuration:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Configuration
public class SolutionConfig {

 @Bean(initMethod = "initMethod", destroyMethod = "destroyMethod")
 public Author author() {
  return new Author("Aplha, Engineer", "alphaengineer@gmail.com");
 }

 @Bean(initMethod = "initMethod", destroyMethod = "destroyMethod")
 public Post post() {
  return new Post("Spring Bean Lifecycle hooks", author());
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Aware Interfaces:-&lt;/p&gt;

&lt;p&gt;Aware interfaces are used to check and configure information about bean name, class loader and Application Context details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Getter
@Setter
@NoArgsConstructor
public class Post implements BeanNameAware, BeanClassLoaderAware, ApplicationContextAware, InitializingBean, DisposableBean {

 private UUID id;
 private String content;
 private Author author;

 public Post(String content, Author author) {
  System.out.println("Author from Post constructor : "+author.toString());
  this.id = UUID.randomUUID();
  this.content = content;
  this.author = author;
 }

 @PostConstruct
 public void init() {
  System.out.println("Post, @PostConstruct annotated method");
 }

 @PreDestroy
 public void predestroy() {
  System.out.println("Post, @PreDestroy annotated method");
 }

 public void initMethod() {
  System.out.println("Post, initMethod method");
 }
 public void destroyMethod() {
  System.out.println("Post, destroyMethod method");
 }

 public void destroy() {
  System.out.println("Post, destroy method from Disposable interface");
 }

 @Autowired
 public void setAuthor(Author author) {
  System.out.println("setAuthor : "+author.toString());
  this.author = author;
 }
 @Override
 public String toString() {
  return "Post [id=" + id + ", content=" + content + ", author=" + author.toString() + "]";
 }

 public void setBeanName(String name) {
  System.out.println("Post, setBeanName method from BeanNameAware interface : "+name);
 }

 public void setBeanClassLoader(ClassLoader classLoader) {
  System.out.println("Post, setBeanClassLoader method BeanClassLoaderAware interface : "+classLoader.getName());
 }

 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  System.out.println("Post, setApplicationContext method ApplicationContextAware interface : "+applicationContext.getApplicationName());
 }

 public void afterPropertiesSet() throws Exception {
  System.out.println("Post, afterPropertiesSet method InitializingBean interface  ");
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Getter
@Setter
@NoArgsConstructor
public class Author implements BeanNameAware, BeanClassLoaderAware, ApplicationContextAware, InitializingBean, DisposableBean {

 private UUID id;
 private String fullName;
 private String email;

 public Author(String fullName, String email) {
  System.out.println("Author constructor");
  this.id = UUID.randomUUID();
  this.fullName = fullName;
  this.email = email;
 }
 @PostConstruct
 public void init() {
  System.out.println("Author, @PostConstruct annotated method");
 }
 @PreDestroy
 public void predestroy() {
  System.out.println("Author, @PreDestroy annotated method");
 }
 public void destroy() {
  System.out.println("Author, destroy method from DisposableBean interface");
 }
 public void initMethod() {
  System.out.println("Author, initMethod method");
 }
 public void destroyMethod() {
  System.out.println("Author, destroyMethod method");
 }
 @Override
 public String toString() {
  return "Author [id=" + id + ", fullName=" + fullName + ", email=" + email + "]";
 }
 public void setBeanName(String name) {
  System.out.println("Author, setBeanName method from BeanNameAware interface : "+name);
 }

 public void setBeanClassLoader(ClassLoader classLoader) {
  System.out.println("Author, setBeanClassLoader method BeanClassLoaderAware interface : "+classLoader.getName());
 }

 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  System.out.println("Author, setApplicationContext method ApplicationContextAware interface : "+applicationContext.getApplicationName());
 }
 public void afterPropertiesSet() throws Exception {
  System.out.println("Author, afterPropertiesSet method InitializingBean interface  ");
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample Output:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Author, setBeanClassLoader method BeanClassLoaderAware interface : app
Author, setApplicationContext method ApplicationContextAware interface : 
Author, @PostConstruct annotated method
Author, afterPropertiesSet method InitializingBean interface  
Author, initMethod method
Author from Post constructor : Author [id=1e360880-50eb-4bdf-a230-1e825ed67b39, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]
setAuthor : Author [id=1e360880-50eb-4bdf-a230-1e825ed67b39, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]
Post, setBeanName method from BeanNameAware interface : post
Post, setBeanClassLoader method BeanClassLoaderAware interface : app
Post, setApplicationContext method ApplicationContextAware interface : 
Post, @PostConstruct annotated method
Post, afterPropertiesSet method InitializingBean interface  
Post, initMethod method
Post : Post [id=ff29cc5a-b05c-448b-aa7d-05fbe17709ca, content=Spring Bean Lifecycle hooks, author=Author [id=1e360880-50eb-4bdf-a230-1e825ed67b39, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]]
Post, @PreDestroy annotated method
Post, destroy method from Disposable interface
Post, destroyMethod method
Author, @PreDestroy annotated method
Author, destroy method from DisposableBean interface
Author, destroyMethod method
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spring Bean Lifecycle Flow:-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dD-San-x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jkagbydvtynv009htkx8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dD-San-x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jkagbydvtynv009htkx8.png" alt="Spring Lifecycle Flow" width="793" height="962"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Spring IoC container first creates the depend beans, inject and then create the bean for usage, then delete the bean and its depend beans. if any runtime exceptions happen in any of these lifecycle hook methods. it breaks the bean instantiation. on successful execution of all these hooks spring bean is ready to use.&lt;/p&gt;

&lt;p&gt;Thanks for spending your valuable time, Think blog is based on my understanding ony, if you feel anything is wrong please feel free to comment.&lt;/p&gt;

&lt;p&gt;Reference:-&lt;br&gt;
&lt;a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/BeanFactory.html"&gt;https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/BeanFactory.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>springframework</category>
      <category>springboot</category>
      <category>springmvc</category>
      <category>springbeanlifecycle</category>
    </item>
    <item>
      <title>ES2019/ES10 Features</title>
      <dc:creator>Prabu Subra</dc:creator>
      <pubDate>Sat, 06 Apr 2019 14:32:33 +0000</pubDate>
      <link>https://dev.to/prabusubra/es2019-es10-features-5b14</link>
      <guid>https://dev.to/prabusubra/es2019-es10-features-5b14</guid>
      <description>&lt;p&gt;Recently, TC39 committee has approved and added few bunch of feature to ECMAScript 2019 Standard, which are ported to major JavaScript engine like V8,SpiderMonkey…&lt;/p&gt;

&lt;h3&gt;
  
  
  Completed Features:-
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Array.prototype.{flat, flatmap}&lt;/li&gt;
&lt;li&gt;String.prototype.{trimStart,trimEnd, matchAll*}&lt;/li&gt;
&lt;li&gt;Object.fromEntries&lt;/li&gt;
&lt;li&gt;Function.prototype.toString&lt;/li&gt;
&lt;li&gt;Sysmbol.prototype.description&lt;/li&gt;
&lt;li&gt;Optional catch binding&lt;/li&gt;
&lt;li&gt;JSON superset&lt;/li&gt;
&lt;li&gt;well-formed JSON.stringify&lt;/li&gt;
&lt;li&gt;BigInt*&lt;/li&gt;
&lt;li&gt;globalThis*&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;* - at stage 3&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Arrays.prototype.{flat, flatmap}
&lt;/h3&gt;

&lt;p&gt;Two methods has added.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Array.prototype.flat&lt;/li&gt;
&lt;li&gt;Array.prototype.flatMap&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Array.prototype.flat:-&lt;/p&gt;

&lt;p&gt;It is originally proposed as Array.prototype.flatten, flattens arrays recursively up to the specified depth, which defaults to 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alpha&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;beta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gamma&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;delta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;epsilon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;zeta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;theta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;iota&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kappa&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]]]&lt;/span&gt;
  &lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
  &lt;span class="c1"&gt;//(5) ["alpha", "beta", "gamma", "delta", Array(3)]&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="c1"&gt;//(7) ["alpha", "beta", "gamma", "delta", "epsilon", "zeta", Array(4)]&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="c1"&gt;//(10) ["alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa"]&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;Infinity&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="c1"&gt;//(10) ["alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Array.prototype.flatMap:-&lt;/p&gt;

&lt;p&gt;Combined flatten and map behaviour for arrays. Flatten the result in to single array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="c1"&gt;//[[2, 3], [4, 6], [6, 9], [8, 12], [10, 15]]&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;//[2, 3, 4, 6, 6, 9, 8, 12, 10, 15];&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;flatMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="c1"&gt;//[2, 3, 4, 6, 6, 9, 8, 12, 10, 15]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  String.prototype.{trimStart,trimEnd, matchAll*}:-
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;String.prototype.trimStart()&lt;/li&gt;
&lt;li&gt;String.prototype.trimEnd()&lt;/li&gt;
&lt;li&gt;String.prototype.matchAll()
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; Hacker Rank  &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;trimStart&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;//Hacker Rank&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;trimEnd&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;//Hacker Rank&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;//["a", index: 2, input: " Hacker Rank  ", groups: undefined]&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;iterator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;matchAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;iterator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
  &lt;span class="cm"&gt;/*let result;
  do {
    result = iterator.next();
    console.log(result);
  } while (!result.done); */&lt;/span&gt;

&lt;span class="c1"&gt;//["a", index: 2, input: " Hacker Rank  ", groups: undefined]&lt;/span&gt;
&lt;span class="c1"&gt;//["a", index: 9, input: " Hacker Rank  ", groups: undefined]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Function.prototype.toString:-
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If function is written ECMAScript code, then toString should return source code.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="cm"&gt;/*"function multiply(a, b) {
    return a * b;
  }"*/&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;return a+b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="cm"&gt;/*"function anonymous(a,b
  ) {
  return a+b
  }"*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;For built-in and binding function, it returns NativeFunction string.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="c1"&gt;//"function stringify() { [native code] }"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Object:-
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;A new static method Object.fromEntries is added to Object.&lt;/li&gt;
&lt;li&gt;To be specific, it converts array of arrays(Array which has nested arrays in it) in to Object, Let’s see, how is it working.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromEntries&lt;/span&gt;&lt;span class="p"&gt;([[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;one&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alpha&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;two&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;beta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;three&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gamma&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]]);&lt;/span&gt;
&lt;span class="c1"&gt;//{one: "alpha", two: "beta", three: "gamma"}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h6&gt;
  
  
  Few Questions:-
&lt;/h6&gt;

&lt;ol&gt;
&lt;li&gt; What if, Nested arrays have more than 2 elements in it?
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromEntries&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
      &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;one&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alpha&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;two&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;beta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;three&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gamma&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;delta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="c1"&gt;//{one: "alpha", three: "gamma"}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt; What if, Array inside arrays contains objects?
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromEntries&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
      &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;one&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alpha&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;two&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;beta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}],&lt;/span&gt;
      &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;three&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gamma&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;four&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;delta&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;
    &lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="c1"&gt;//{[object Object]: {four: "delta"}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Symbol:-
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;As we know, Symbol is built in datatype for unique identifiers, we can create hidden properties for an object.&lt;/li&gt;
&lt;li&gt;A new property Symbol.prototype.description is added to get description from symbol.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;connectionUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CONNECTION_URL&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onnectionUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//"CONNECTION_URL"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Examples:-
Symbol.iterator, Symbol.asyncIterator,Symbol.match,Symbol.matchAll...&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Catch binding:-
&lt;/h3&gt;

&lt;p&gt;If there is no use of exceptions details in catch block, developer can remove catch binding happily. This will remove unused and boilerplate code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Not a valid number!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  BigInt:-
&lt;/h3&gt;

&lt;p&gt;A BigInt is created by appending &lt;strong&gt;&lt;em&gt;n to the end of the integer&lt;/em&gt;&lt;/strong&gt; or by calling the &lt;strong&gt;&lt;em&gt;constructor&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bnum1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bnum2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//10n&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bnum3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;10.5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//(d8):1: RangeError: The number 10.5 cannot be converted to a BigInt because it is not an integer.&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bnum4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;10.5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//(d8):1: SyntaxError: Cannot convert 10.5 to a BigInt.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;BigInt can’t mix with numbers, but can concat with strings.&lt;/li&gt;
&lt;li&gt;Can’t use decimals.&lt;/li&gt;
&lt;li&gt;parseInt returns number.&lt;/li&gt;
&lt;li&gt;JSON.stringify doesn't support.&lt;/li&gt;
&lt;li&gt;TypedArray
BigInt64Array (-263 to 263-1)
BigUint64Array (0 to 264-1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  globalThis:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Accessing global object from browser(window), node(global)...&lt;/li&gt;
&lt;li&gt;globalThis will infer the enviroment and return the global object .
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;getGlobal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;global&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;unable to locate global object&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Conclusion:-&lt;/p&gt;

&lt;p&gt;As we know, ECMAScript standards are used in various programming languages like Microsoft’s JScript, Oracle Nashorn Engine, it is strictly based on the language engine to choose which standard to support. let’s keep an eye on TC39 proposal for latest updates.&lt;/p&gt;

&lt;p&gt;Thanks for reading!!!&lt;/p&gt;

&lt;p&gt;Please feel free to comment your suggestions.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>es2019</category>
      <category>ecmascript2019</category>
      <category>es10</category>
    </item>
    <item>
      <title>Local Variables Type Inference in Java</title>
      <dc:creator>Prabu Subra</dc:creator>
      <pubDate>Tue, 01 Jan 2019 09:46:24 +0000</pubDate>
      <link>https://dev.to/prabusubra/var-in-java-492m</link>
      <guid>https://dev.to/prabusubra/var-in-java-492m</guid>
      <description>&lt;p&gt;To be short, This post is about a type called &lt;strong&gt;var&lt;/strong&gt;, which is introduced in java 10. Before started using var type, i have analysed and summarised about where to use and not to use var type like as an argument for methods, constructors, Exceptions, lambdas, Streams, etc...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;var&lt;/strong&gt; - Type Inference for local variables.&lt;/p&gt;

&lt;p&gt;Before start using var, we need to understand few questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is var ? what is the use of it ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is used to declare local variables and reduces the boilerplate code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is it a new keyword introduced in java ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The answer is big &lt;strong&gt;No&lt;/strong&gt;, it is not a keyword, a new type called var has created to improve type inference. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is java becoming dynamic type language like JavaScript ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No&lt;/strong&gt;, Added an intelligent for compiler to understand the type of the local variable using its initializer without specifying explicitly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How are the possible ways to declare local variables?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Examples:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;(); // level 1
List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;&amp;gt;(); // level 2
var list = new ArrayList&amp;lt;String&amp;gt;(); // level 3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There are the places to use and not to use. Lets see few of that.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;tr&gt;
   &lt;td&gt;Scenario
   &lt;/td&gt;
   &lt;td&gt;Example
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot use var without initializer.
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; var a;&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  cannot infer type for local variable a&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| (cannot use 'var' on variable without initializer)&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  var a;&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot initialize with null.
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; var a=null&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  cannot infer type for local variable a&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| (variable initializer is 'null')&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  var a=null;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  ^---------^&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot use with arrays
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; var[] a = new int[]{1,2,3}&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' is not allowed as an element type of an array&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot use Multi variable declarations
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; var a = "Alpha",b="Beta",c="Gamma";&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' is not allowed in a compound declaration&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  var a = "Alpha",b="Beta",c="Gamma";&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|                 ^&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' is not allowed in a compound declaration&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  var a = "Alpha",b="Beta",c="Gamma";&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Variables, methods can be named var.
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; var var = "Hello World!!!"&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;var ==&amp;gt; "Hello World!!!"&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; /l var&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;   1 : var var = "Hello World!!!";&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; public void var() { System.out.println("Hello world!!!");}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  created method var()&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; var()&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;Hello world!!!&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Classes and Interfaces can't be named var
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; class var {}&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' not allowed here&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| as of release 10, 'var' is a restricted local variable type and cannot be used for type declarations&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  class var {}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|     ^&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; interface var {}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' not allowed here&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| as of release 10, 'var' is a restricted local variable type and cannot be used for type declarations&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  interface var {}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|         ^&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Can be used with collections
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; var list = List.of("alpha","beta","gamma");&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;list ==&amp;gt; [alpha, beta, gamma]&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; /v list&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| List list = [alpha, beta, gamma]&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; var set = Set.of("alpha","beta","gamma");&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;set ==&amp;gt; [beta, gamma, alpha]&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; /v set&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| Set set = [beta, gamma, alpha]&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; var map = Map.of(Map.entry("name","PrabuSubra"),Map.entry("city","Bangalore"))&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;map ==&amp;gt; {name=PrabuSubra=city=Bangalore}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; /v map&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| Map,Map.Entry&amp;gt; map = {name=PrabuSubra=city=Bangalore}&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot use in method/Constructor arguments
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; public void displayError(var errorMessage) { System.out.println(" Error due to : "+errorMessage);}&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' is not allowed here&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  public void displayError(var errorMessage) { System.out.println(" Error due to : "+errorMessage);}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|                         ^-^&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot used as return type in method signature.
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; public var displayError(String errorMessage) { return "Error due to : "+errorMessage;}&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' is not allowed here&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  public var displayError(String errorMessage) { return "Error due to : "+errorMessage;}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|         ^-^&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Can be used in loops.
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; for(var templist : list){   System.out.println(templist);&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;for(var i = 0;i
&lt;p&gt;
&lt;code&gt;}&lt;/code&gt;
   &lt;/p&gt;&lt;/code&gt;&lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Can be used with Streams
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;shell&amp;gt; var streams = Stream.of("alpha","Beta","Gamme","delta","Epsilon");&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;streams ==&amp;gt; java.util.stream.ReferencePipeline$Head@1bce4f0a&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; /v streams&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| Stream streams = java.util.stream.ReferencePipeline$Head@1bce4f0a&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot assigned Functional interfaces to it.
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; var function = (data)-&amp;gt;data&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  cannot infer type for local variable function&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| (lambda expression needs an explicit target-type)&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  var function = (data)-&amp;gt;data;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  ^--------------------------^&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; var consumer = (data)-&amp;gt;{}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  cannot infer type for local variable consumer&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| (lambda expression needs an explicit target-type)&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  var consumer = (data)-&amp;gt;{};&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  ^------------------------^&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; var supplier = ()-&amp;gt;{return new String("Hello world!!!");}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  cannot infer type for local variable supplier&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| (lambda expression needs an explicit target-type)&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  var supplier = ()-&amp;gt;{return new String("Hello world!!!");};&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  ^--------------------------------------------------------^&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; var runnable = ()-&amp;gt;{}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  cannot infer type for local variable runnable&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;| (lambda expression needs an explicit target-type)&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  var runnable = ()-&amp;gt;{};&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  ^--------------------^&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot use with Exception handlers
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; try { } catch (var e){}&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' is not allowed here&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  try { } catch (var e){}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|                 ^-^&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot assign to interface, it always reference to initializer type.
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; var list = new ArrayList()&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;list ==&amp;gt; []&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt; /v list&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|    ArrayList list = []&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;jshell&amp;gt;&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
   &lt;td&gt;Cannot used with type inference.
   &lt;/td&gt;
   &lt;td&gt;
&lt;code&gt;jshell&amp;gt; class Alpha  { var t;}&lt;/code&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' not allowed here&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|    as of release 10, 'var' is a restricted local variable type and cannot be used for type declarations&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  class Alpha  { var t;}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|               ^&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  Error:&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  'var' is not allowed here&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|  class Alpha  { var t;}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;|                      ^-^&lt;/code&gt;
   &lt;/p&gt;
&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Law of var:-&lt;br&gt;
    Properly initialised, Non-array variables can use the luxury of var type inference.&lt;/p&gt;

&lt;p&gt;Summary:-&lt;br&gt;
    Eventually, Java has added few spoon of sugar to existing Type Inference feature. it is not completely freed developers hands to use var in code, it comes with its own laws. Type inference is not completely new feature in java, it has improved a step to use for local variables,mostly to avoid boilerplate code with less upgrade hurdles. The target source code base shouldn't contains class or interface, which was named as var and possibility also rare, nearly nothing. It is one of the way(not only way) to declare local variables.&lt;/p&gt;

&lt;p&gt;Reference:-&lt;/p&gt;

&lt;p&gt;&lt;a href="http://openjdk.java.net/jeps/286"&gt;http://openjdk.java.net/jeps/286&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html"&gt;https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prabusubra/Learning/blob/master/Java/JShell/jshell.txt"&gt;https://github.com/prabusubra/Learning/blob/master/Java/JShell/jshell.txt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note:- if you feel something has to be added or wrong, feel free to comment below. Thanks for reading!!!&lt;/p&gt;

</description>
      <category>java</category>
    </item>
    <item>
      <title>Understanding docker Containers and images</title>
      <dc:creator>Prabu Subra</dc:creator>
      <pubDate>Sat, 24 Nov 2018 19:11:28 +0000</pubDate>
      <link>https://dev.to/prabusubra/understanding-docker-containers-and-images-ed7</link>
      <guid>https://dev.to/prabusubra/understanding-docker-containers-and-images-ed7</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqai4egmubnu0joejw23.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqai4egmubnu0joejw23.png" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Containers — A technology to run one or more than one process on an independent and isolated environment.&lt;/p&gt;

&lt;p&gt;What are process here?&lt;br&gt;
    Execution of programs(set of instructions). It could be applications, databases,  message queues, etc…&lt;/p&gt;

&lt;p&gt;What are resources needed to execute a process standalone?&lt;/p&gt;

&lt;p&gt;Memory&lt;br&gt;
CPU&lt;br&gt;
I/O devices&lt;br&gt;
Files Systems&lt;/p&gt;

&lt;p&gt;In our day to day life, we use the containers without knowing. For example Parallel Space/Secondary space and Dual apps features in Android mobiles are using Linux Container technology.&lt;/p&gt;

&lt;p&gt;In Linux kernel, we have options to create more than one parallel space and run a process inside of it, like jail, These are called as containers.&lt;/p&gt;

&lt;p&gt;Linux kernel features behind containers:-&lt;/p&gt;

&lt;p&gt;Using linux Kernel features like Namespace, Cgroup, chroot and UnionFS, host Linux kernel can split it's resources to run a process on isolated environment.&lt;/p&gt;

&lt;p&gt;Namespaces → This feature isolates below terms from host and other containers.&lt;/p&gt;

&lt;p&gt;Mount — isolate filesystem mount points.&lt;br&gt;
UTS — isolate hostname and domain name.&lt;br&gt;
IPC — isolate interprocess communication (IPC) resources.&lt;br&gt;
PID — isolate the PID number space.&lt;br&gt;
Network — isolate network interfaces.&lt;br&gt;
User — isolate UID/GID number spaces.&lt;/p&gt;

&lt;p&gt;Cgroups → limits resources like CPU, memory, network...&lt;/p&gt;

&lt;p&gt;Chroot → change the root directory for specified process and its child processes.&lt;/p&gt;

&lt;p&gt;UnionFS → layered File system. &lt;br&gt;
                1. Immutable layers&lt;br&gt;
                        docker images are build as immutable layers.&lt;br&gt;
                2. Mutable layers&lt;br&gt;
                        Data are persisted on this layer. it can be mounted to&lt;br&gt;&lt;br&gt;
                        local storage or external cloud store.&lt;br&gt;
it helps for effective reuse of docker image and data management.&lt;/p&gt;

&lt;p&gt;If containers share host operating systems, then&lt;/p&gt;

&lt;p&gt;Why do we have operating system images(Container OS) on docker registries?&lt;br&gt;
    Containers are running on Host kernel, but OS utilities and libraries are not available, because of isolation(Namespace). Containers cannot access softwares installed on Host OS. so we have to configure required software for each docker container as docker image in Dockerfile.&lt;/p&gt;

&lt;p&gt;What is actually is operating systems image(Container OS)?&lt;br&gt;
    These images are not full fledged Operating systems, just a bunch of utilities/libraries.&lt;/p&gt;

&lt;p&gt;Therefore, To run a container, we just need to load few utilities not full operating systems.&lt;/p&gt;

&lt;p&gt;Docker Container CLIs:-&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhw7ig0ksj3gfr2q2vbm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhw7ig0ksj3gfr2q2vbm.png" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Images — A blueprint or template, from which one or more than one containers can be created.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ykspyfo27rrqd3wkrmg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ykspyfo27rrqd3wkrmg.png" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most of the images are build based on Scratch image. It is like super parent image. Scratch doesn’t have any utility, it is empty image with zero size. image size is depends on its utilities, libraries and apps.&lt;/p&gt;

&lt;p&gt;Docker image CLIs:-&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7oxzsu6zfm4fi7i5oku5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7oxzsu6zfm4fi7i5oku5.png" width="688" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dockerfile:-&lt;/p&gt;

&lt;p&gt;Docker image is created from Dockerfile. it has a set of vocabularies to execute processes with its dependencies independently.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3fdcabe4wkn34wputz9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3fdcabe4wkn34wputz9.png" width="676" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Eventually, using container technology software can be created/changed, packed, tested and shipped quicker with less hurdles than traditional ways. It simplifies software business. programmable Platform (PaaS) accelerate software development and deployment(SaaS).&lt;/p&gt;

&lt;p&gt;Thanks for reading… This is my understanding after using docker for few months. Feel free to comment your suggestions !!!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>container</category>
      <category>linuxkernel</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Reactive Sprint Boot application using WebFlux</title>
      <dc:creator>Prabu Subra</dc:creator>
      <pubDate>Wed, 05 Sep 2018 13:04:43 +0000</pubDate>
      <link>https://dev.to/prabusubra/reactive-sprint-boot-application-using-webflux-bj7</link>
      <guid>https://dev.to/prabusubra/reactive-sprint-boot-application-using-webflux-bj7</guid>
      <description>&lt;p&gt;A Reactive Spring Boot application can be written in&lt;br&gt;
        &lt;strong&gt;- Imperative style(Spring WebMVC)&lt;/strong&gt; or&lt;br&gt;
        &lt;strong&gt;- Declarative Style(Spring WebFlux).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What is Reactive Spring Boot application?&lt;/p&gt;

&lt;p&gt;it is a implementation of reactive streams(i.e sequence of data pushed from source to subscribers with back pressure), which are non-blocking, asynchronous and event-driven by nature. Spring Reactive libraries are build as part of Project Reactor projectreactor.io.&lt;/p&gt;

&lt;p&gt;What is imperative style?&lt;/p&gt;

&lt;p&gt;it is not imperative programming just a imperative programming style. it means Reactive Spring boot application can be written using sprint mvc annotations, so with minimum modifications, the old, legacy, big applications can also be converted to reactive nature and can use its features and benefits.&lt;/p&gt;

&lt;p&gt;What is declarative style?&lt;/p&gt;

&lt;p&gt;it is the latest functional lambda style of programming, this would be the better for new applications which are starting from scratch. let move further.&lt;/p&gt;

&lt;p&gt;i recently converted my code base from Spring web-mvc to web-flux model. Initially, i faced few difficulties to understand and use Routers, Handlers and lambda functions, so i thought, writing a flat and simple controllers and equivalent Routers for same use cases will simplify the understanding.&lt;/p&gt;

&lt;p&gt;As of now, spring boot apps can be developed in Spring WebMVC or WebFlux model, it is like... this or that, not a mix of both in a single application. so you shouldn’t have RestController annotation or spring-boot-starter-web dependency in pom.xml, if you are using spring web-flux routers.&lt;/p&gt;

&lt;p&gt;REST endpoint should be defined on Configuration annotated class as a Bean of RouerFunction, Neither as a RestController nor Controller annotations.&lt;/p&gt;

&lt;p&gt;Spring webflux is a programming paradigm used to compose Spring Boot applications on functional style(declarative style) using lambda functions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ifSSmU_4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ylw0d0vqaz1tld0lakz3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ifSSmU_4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ylw0d0vqaz1tld0lakz3.png" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;lets see some code on each model. i have used below bean and written few GET/POST/DELETE Rest endpoints.&lt;/p&gt;

&lt;p&gt;Bean:-&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;REST end points in Spring Web-MVC:-&lt;/p&gt;

&lt;p&gt;Here everything is defined using annotations.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;REST endpoints in Spring WebFlux:-&lt;/p&gt;

&lt;p&gt;Few bunch of annotations are replaced with lambda functions, Not all the annotations. it is working with combination of annotations and lambda functions.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;For better re usability/structure of code, we can have a dedicated handler and utility classes as Spring Component or Service.&lt;/p&gt;

&lt;p&gt;Conclusion:-&lt;/p&gt;

&lt;p&gt;Eventually, Controller becomes Router. Request and Response related annotations become lambda functions, it may look like Spring framework is moving towards lambda function based configurations (XML → Annotations → lambda functions). but still annotations are playing huge role, even RouterFunction itself configured with Configuration and Bean annotations.&lt;/p&gt;

&lt;p&gt;Refer the below git hub repository for code.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/prabusubra"&gt;
        prabusubra
      &lt;/a&gt; / &lt;a href="https://github.com/prabusubra/microservicelearning"&gt;
        microservicelearning
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
microservicelearning&lt;/h1&gt;
&lt;p&gt;This repo is to learn about microservice architecture and related technologies.&lt;/p&gt;
&lt;p&gt;REST endpoints for WebMVC:- &lt;br&gt;&lt;/p&gt;
&lt;p&gt;GET - &lt;a href="http://localhost:7070/api/blogs" rel="nofollow"&gt;http://localhost:7070/api/blogs&lt;/a&gt; &lt;br&gt;
GET - &lt;a href="http://localhost:7070/api/blogs/id/%7Bid%7D" rel="nofollow"&gt;http://localhost:7070/api/blogs/id/{id}&lt;/a&gt; &lt;br&gt;
POST - &lt;a href="http://localhost:7070/api/blogs" rel="nofollow"&gt;http://localhost:7070/api/blogs&lt;/a&gt; &lt;br&gt;
Request body :-&lt;br&gt;
[
{
"topicid": "webflux",
"name": "webflux",
"content": "Intro and operators",
"author": "Josh Long",
"category": null
},
{
"topicid": "react",
"name": "React",
"content": "Intro and operators",
"author": "Josh Long",
"category": null
},
{
"topicid": "projectreactor",
"name": "projectreactor",
"content": "Intro and operators",
"author": "Josh Long",
"category": null
},
{
"topicid": "restmvc",
"name": "restmvc",
"content": "Intro and annotations",
"author": "Josh Long",
"category": null
}
]
&lt;br&gt;
DELETE - &lt;a href="http://localhost:7070/api/blogs/id/%7Bid%7D" rel="nofollow"&gt;http://localhost:7070/api/blogs/id/{id}&lt;/a&gt;
&lt;br&gt;
REST endpoints for WebFlux:-
&lt;br&gt;
GET - &lt;a href="http://localhost:6060/api/blogs" rel="nofollow"&gt;http://localhost:6060/api/blogs&lt;/a&gt; &lt;br&gt;
GET - &lt;a href="http://localhost:6060/api/blogs/id/%7Bid%7D" rel="nofollow"&gt;http://localhost:6060/api/blogs/id/{id}&lt;/a&gt; &lt;br&gt;
POST - &lt;a href="http://localhost:6060/api/blogs" rel="nofollow"&gt;http://localhost:6060/api/blogs&lt;/a&gt; &lt;br&gt;
DELETE - &lt;a href="http://localhost:7070/api/blogs/id/%7Bid%7D" rel="nofollow"&gt;http://localhost:7070/api/blogs/id/{id}&lt;/a&gt; &lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/prabusubra/microservicelearning"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;&lt;a href="https://medium.com/letscode/sprint-boot-application-using-spring-webmvc-and-webflux-d94672b70595"&gt;Medium Post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for spending your valuable time!!! please feel free to comment your views or suggestions…&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>springwebflux</category>
      <category>reactiveprogramming</category>
      <category>spring</category>
    </item>
  </channel>
</rss>
