<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Class Declaration Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/class-declaration/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/class-declaration/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Wed, 13 Apr 2022 16:30:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>How do classes work in JavaScript?</title>
		<link>https://www.scmgalaxy.com/tutorials/how-do-classes-work-in-javascript/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-do-classes-work-in-javascript/#respond</comments>
		
		<dc:creator><![CDATA[rajeshkumar]]></dc:creator>
		<pubDate>Wed, 04 Aug 2021 10:37:54 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Class Declaration]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[Javascript]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=7377</guid>

					<description><![CDATA[<p>Class JavaScript classes, introduced in ECMAScript 2015 or ES 6, Classes are in fact &#8220;special functions&#8221;.There are two ways to [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-do-classes-work-in-javascript/">How do classes work in JavaScript?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Class</h2>



<p class="wp-block-paragraph">JavaScript classes, introduced in ECMAScript 2015 or ES 6, Classes are in fact &#8220;special functions&#8221;.<br><strong>There are two ways to define a class in JavaScript using class</strong> <strong>keyword:-</strong></p>



<ul class="wp-block-list"><li><strong>Class Declaration</strong></li><li><strong>Class Expression</strong></li></ul>



<h2 class="wp-block-heading">Class Declaration</h2>



<script src="https://gist.github.com/vijaypk376/974621414c83de4c47a06fc8d87aa16f.js"></script>



<h2 class="wp-block-heading">Constructor</h2>



<p class="wp-block-paragraph">The constructor method is a special method for creating and initializing an object created within a class. There can be only one special method with the name &#8220;constructor&#8221; in a class.</p>



<script src="https://gist.github.com/vijaypk376/3d6e81bb58ac1c06c5a8ea754085a471.js"></script>



<h2 class="wp-block-heading">Default Constructor</h2>



<p class="wp-block-paragraph">If you do not specify a constructor method a default constructor is used.</p>



<script src="https://gist.github.com/vijaypk376/6702713627450d4ab23989a0729ca7ba.js"></script>



<script src="https://gist.github.com/vijaypk376/1ccf561e940d0458f29d8b2b3b841cde.js"></script>



<h2 class="wp-block-heading">Parameterized Constructor</h2>



<script src="https://gist.github.com/vijaypk376/a0cbba23bfd43b943ebf8f170495b879.js"></script>



<h2 class="wp-block-heading">Class Expression</h2>



<p class="wp-block-paragraph">Class expressions can be named or unnamed.</p>



<script src="https://gist.github.com/vijaypk376/d39d0da6e8ff44610fbd6dfd2125cf5c.js"></script>



<h2 class="wp-block-heading">Class Hoisting</h2>



<p class="wp-block-paragraph">Class Declarations and Class Expression are not hoisted. You first need to declare your class and then access it.</p>



<script src="https://gist.github.com/vijaypk376/ba7cb5a6bb01b9ef92377df171661a88.js"></script>



<h2 class="wp-block-heading">Inheritance</h2>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="942" height="358" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/08/inheritance.png" alt="" class="wp-image-7378" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/08/inheritance.png 942w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/08/inheritance-300x114.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/08/inheritance-768x292.png 768w" sizes="(max-width: 942px) 100vw, 942px" /></figure>



<h2 class="wp-block-heading">Class Inheritance</h2>



<p class="wp-block-paragraph">The extends keyword is used in class declarations or class expressions to create a class that is a child of another class.<br>The extended keyword can be used to subclass custom classes as well as built-in objects.</p>



<script src="https://gist.github.com/vijaypk376/9445111d6b5f126178175f99ff892466.js"></script>



<h2 class="wp-block-heading">Class Inheritance</h2>



<ul class="wp-block-list"><li><strong>Inherit Built-in Object</strong></li></ul>



<p class="wp-block-paragraph"><strong>     – Date<br>    – String<br>    – Array</strong></p>



<p class="wp-block-paragraph">class myDate extends Date {<br>}</p>



<h2 class="wp-block-heading">Super</h2>



<p class="wp-block-paragraph">Super ( ) is used to initialize parent class constructor. If there is a constructor present in a subclass,<br>it needs to first call super() before using &#8220;this&#8221;. A constructor can use the super keyword to call the<br>constructor of a parent class.</p>



<script src="https://gist.github.com/vijaypk376/8ea04efa899dadf152c53bf0cf4fb147.js"></script>



<h2 class="wp-block-heading">Method Overriding</h2>



<p class="wp-block-paragraph">Same function name with different implementation.</p>



<p class="wp-block-paragraph">Parent &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;>   show ( ) {return “Super Class”; }<br>Child &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;>  show ( ) {return “Sub Class”; } show ( ) {return “Super Class”; }</p>



<h2 class="wp-block-heading">Static Method</h2>



<p class="wp-block-paragraph">The static keyword is used to define a static method for a class. Static methods are called without creating object and cannot be called through a class instance (object). Static methods are often used to create utility functions for an<br>application.</p>



<script src="https://gist.github.com/vijaypk376/c4ebef30dbdcdbed4e2addf8d02c9748.js"></script>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-do-classes-work-in-javascript/">How do classes work in JavaScript?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-do-classes-work-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
