<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4006,"date":"2022-03-26T12:33:08","date_gmt":"2022-03-26T12:33:08","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4006"},"modified":"2022-05-04T07:09:17","modified_gmt":"2022-05-04T07:09:17","slug":"what-is-arrow-function-in-react-how-is-it-used","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/","title":{"rendered":"What is Arrow function in React ? How is it used ?"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4272\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png\" alt=\"\" width=\"954\" height=\"635\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png 954w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions-300x200.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions-768x511.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions-390x260.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions-820x546.png 820w\" sizes=\"(max-width: 954px) 100vw, 954px\" \/><\/p>\n<ul>\n<li style=\"text-align: justify;\">They are more of a brief syntax for writing the function expression. It is also known as <em>\u2018fat arrow<\/em> \u2018(<strong>=&gt;<\/strong>) the functions.<\/li>\n<li style=\"text-align: justify;\">This keyword represented the object that called the function, which could be the window, the document, a button or whatever in a regular function.<\/li>\n<li style=\"text-align: justify;\">It allows to bind the context of the components properly since in ES6 auto binding is not available by default.<\/li>\n<li style=\"text-align: justify;\">While working with the higher-order functions, Arrow functions are most useful.<\/li>\n<li style=\"text-align: justify;\">This keyword <em>always<\/em>\u00a0represents the object that defined the arrow function in arrow function.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-4274\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-function.jpg\" alt=\"\" width=\"1057\" height=\"728\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-function.jpg 1057w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-function-300x207.jpg 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-function-1024x705.jpg 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-function-768x529.jpg 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-function-390x269.jpg 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-function-820x565.jpg 820w\" sizes=\"(max-width: 1057px) 100vw, 1057px\" \/><\/p>\n<p>For example, in <strong>regular<\/strong> <strong>functions:<\/strong><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">class Header {<br\/>  constructor() {<br\/>    this.color = &quot;Blue&quot;;<br\/>  }<br\/><br\/>\/\/Regular function:<br\/>  changeColor = function() {<br\/>    document.getElementById(&quot;demo&quot;).innerHTML += this;<br\/>  }<br\/>}<br\/><br\/>const myheader = new Header();<br\/><br\/>\/\/The window object calls the function:<br\/>window.addEventListener(&quot;load&quot;, myheader.changeColor);<br\/><br\/>\/\/A button object calls the function:<br\/>document.getElementById(&quot;btn&quot;).addEventListener(&quot;click&quot;, myheader.changeColor);<\/code><\/pre> <\/div>\n<p>For example, in <strong>Arrow<\/strong> <strong>functions:<\/strong><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">class Header {<br\/>  constructor() {<br\/>    this.color = &quot;Blue&quot;;<br\/>  }<br\/><br\/>\/\/Arrow function:<br\/>  changeColor = () =&gt; {<br\/>    document.getElementById(&quot;demo&quot;).innerHTML += this;<br\/>  }<br\/>}<br\/><br\/>const myheader = new Header();<br\/><br\/><br\/>\/\/The window object calls the function:<br\/>window.addEventListener(&quot;load&quot;, myheader.changeColor);<br\/><br\/>\/\/A button object calls the function:<br\/>document.getElementById(&quot;btn&quot;).addEventListener(&quot;click&quot;, myheader.changeColor);<\/code><\/pre> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>They are more of a brief syntax for writing the function expression. It is also known as \u2018fat arrow \u2018(=&gt;) the functions. This keyword represented the object that called the function, which could be the window, the document, a button or whatever in a regular function. It allows to bind the context of the components [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[16542],"tags":[16778,16788,16781,16777,16785,16782,16783,16779,16780,16776,16784,16787,16786],"class_list":["post-4006","post","type-post","status-publish","format-standard","hentry","category-reactjs","tag-arrow-function-in-react","tag-arrow-function-in-react-example","tag-arrow-function-in-react-native","tag-passing-functions-to-components","tag-react-arrow-function","tag-react-arrow-function-component","tag-react-arrow-function-props","tag-react-arrow-function-vs-function","tag-react-arrow-function-with-parameters","tag-react-es6-arrow-functions","tag-react-onclick-arrow-function","tag-what-is-arrow-function-in-react","tag-what-is-arrow-function-in-react-how-is-it-used"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Arrow function in React ? How is it used ? - React<\/title>\n<meta name=\"description\" content=\"What is Arrow function in React ? How is it used ? - React - They are more of brief syntax for writing the function expression.\" \/>\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.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Arrow function in React ? How is it used ? - React\" \/>\n<meta property=\"og:description\" content=\"What is Arrow function in React ? How is it used ? - React - They are more of brief syntax for writing the function expression.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-26T12:33:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-04T07:09:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/\",\"name\":\"What is Arrow function in React ? How is it used ? - React\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png\",\"datePublished\":\"2022-03-26T12:33:08+00:00\",\"dateModified\":\"2022-05-04T07:09:17+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is Arrow function in React ? How is it used ? - React - They are more of brief syntax for writing the function expression.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png\",\"width\":954,\"height\":635},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Arrow function in React ? How is it used ? - React","description":"What is Arrow function in React ? How is it used ? - React - They are more of brief syntax for writing the function expression.","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.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/","og_locale":"en_US","og_type":"article","og_title":"What is Arrow function in React ? How is it used ? - React","og_description":"What is Arrow function in React ? How is it used ? - React - They are more of brief syntax for writing the function expression.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/","og_site_name":"Wikitechy","article_published_time":"2022-03-26T12:33:08+00:00","article_modified_time":"2022-05-04T07:09:17+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/","name":"What is Arrow function in React ? How is it used ? - React","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png","datePublished":"2022-03-26T12:33:08+00:00","dateModified":"2022-05-04T07:09:17+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is Arrow function in React ? How is it used ? - React - They are more of brief syntax for writing the function expression.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-is-arrow-function-in-react-how-is-it-used\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/arrow-functions.png","width":954,"height":635},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4006"}],"version-history":[{"count":3,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4006\/revisions"}],"predecessor-version":[{"id":4275,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4006\/revisions\/4275"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}