<?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>javascript function Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/javascript-function/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/javascript-function/</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 to Write Function in JavaScript?</title>
		<link>https://www.scmgalaxy.com/tutorials/how-to-write-function-in-javascript/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-to-write-function-in-javascript/#respond</comments>
		
		<dc:creator><![CDATA[rajeshkumar]]></dc:creator>
		<pubDate>Fri, 30 Jul 2021 12:56:48 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Arguments]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[javascript function]]></category>
		<category><![CDATA[Parameters]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=7198</guid>

					<description><![CDATA[<p>Function Function are subprograms which are used to compute a value or perform a task. Type of Function &#8211; Library [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-write-function-in-javascript/">How to Write Function 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">Function</h2>



<p class="wp-block-paragraph">Function are subprograms which are used to compute a value or perform a task.</p>



<h2 class="wp-block-heading"><strong>Type of Function</strong></h2>



<p class="wp-block-paragraph"><strong>&#8211;</strong> <strong>Library or Built-in functions </strong></p>



<p class="wp-block-paragraph">  Ex: &#8211; valueOf( ) , write( ), alert( ) etc</p>



<p class="wp-block-paragraph"><strong>&#8211; User-defined functions</strong></p>



<h2 class="wp-block-heading">Creating and Calling a Function</h2>



<p class="wp-block-paragraph"><strong>Creating a Function</strong></p>



<p class="wp-block-paragraph">Syntax: &#8211;</p>



<p class="wp-block-paragraph">function function_name( )<br>{<br>Block of statement;<br>}</p>



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



<p class="wp-block-paragraph"><strong>Calling a Function</strong></p>



<p class="wp-block-paragraph">Syntax: &#8211;<br>function_name( );</p>



<p class="wp-block-paragraph">Ex: &#8211;<br>display( );</p>



<h2 class="wp-block-heading">Rules of <strong>Function</strong></h2>



<ul class="wp-block-list"><li>Function name only starts with a letter, an underscore ( _ ).</li><li>Function name cannot start with a number.</li><li>Do not use reserved keywords. e.g. else, if etc.</li><li>Function names are case-sensitive in JavaScript.</li></ul>



<h2 class="wp-block-heading">How Function Call Works</h2>



<p class="wp-block-paragraph">The code inside a function isn‟t executed until that function is called.</p>



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



<h2 class="wp-block-heading">Function with Parameters</h2>



<p class="wp-block-paragraph">Syntax: &#8211;<br>function function_name (parameter1, parameter2, ….)<br>{<br>Block of statement;<br>}</p>



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



<ul class="wp-block-list"><li>JavaScript function definitions do not specify data types for parameters.</li><li>JavaScript functions do not perform type checking on the passed arguments.</li><li>JavaScript functions do not check the number of arguments received.</li></ul>



<h2 class="wp-block-heading">Call Function with Parameter</h2>



<p class="wp-block-paragraph">Syntax: &#8211;<br>function function_name (para1, para2, ….)<br>{<br>Block of statement;<br>}<br>Syntax:-<br>function_name(argument1, argument2);</p>



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



<h2 class="wp-block-heading">Function Argument Missing</h2>



<p class="wp-block-paragraph">If a function is called with missing arguments, the missing values are set to undefined.</p>



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



<h2 class="wp-block-heading">Arguments Object</h2>



<p class="wp-block-paragraph">The arguments object contains an array of the arguments used when the function was called.<br>This object contains an entry for each argument passed to the function, the first entry&#8217;s index starting at 0. The argument&#8217;s object is not an Array. It is similar to an Array but does not have any Array properties except length.</p>



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



<h2 class="wp-block-heading">Many Function Arguments</h2>



<p class="wp-block-paragraph">If a function is called with too many arguments, these arguments can be reached using the arguments object which is a built-in.</p>



<script src="https://gist.github.com/vijaypk376/8633149b98995bd061ab2bf000d92ce8.js"></script>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-write-function-in-javascript/">How to Write Function 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-to-write-function-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Difference between Function and Method in JavaScript</title>
		<link>https://www.scmgalaxy.com/tutorials/difference-between-function-and-method-in-javascript/</link>
					<comments>https://www.scmgalaxy.com/tutorials/difference-between-function-and-method-in-javascript/#comments</comments>
		
		<dc:creator><![CDATA[abhishek k]]></dc:creator>
		<pubDate>Fri, 26 Mar 2021 03:36:17 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[Difference between Function and Method in JavaScript]]></category>
		<category><![CDATA[Function and Method in JavaScript]]></category>
		<category><![CDATA[javascript function]]></category>
		<category><![CDATA[javascript methods]]></category>
		<category><![CDATA[what is the difference between function and javascritp]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5767</guid>

					<description><![CDATA[<p>So what’s the different between the two? Methods have a “receiver” while functions do not. Functions and methods are the [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/difference-between-function-and-method-in-javascript/">Difference between Function and Method in JavaScript</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-medium-font-size wp-block-paragraph"><strong>So what’s the different between the two?</strong></p>



<ul class="wp-block-list"><li><strong>Methods have a “receiver” while functions do not.</strong></li><li><strong>Functions </strong>and <strong>methods </strong>are the same in JavaScript, but a <strong>method </strong>is a <strong>function</strong>, which is a property of an object.</li><li>Syntax for <strong>calling/ definition/declaration</strong> of <strong>functions </strong>and <strong>methods </strong>are different.</li><li>A function can be called directly by its name but methods are called by its object name and its method name using dot notation or square bracket notation.</li><li><strong>Function </strong>passes the data and <strong>methods </strong>operates the data passed in the <em>class</em>.</li><li>A function lives on its own but method is a function associated with an object property.</li><li>Data passed to a function is explicit but method implicitly passes the object on which it was called.</li></ul>



<p class="has-medium-font-size wp-block-paragraph"><strong>Lets see detailed difference between them:-</strong></p>



<p class="wp-block-paragraph">A function in JavaScript is similar to a procedure —>a set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output </p>



<p class="wp-block-paragraph"><strong>Few Important things of functions:-</strong></p>



<ul class="wp-block-list"><li>The function is executed when something calls/invokes it.</li><li>The name may contain letters, digits, dollar signs, underscore.</li><li>Parameters are listed inside round parenthesis after the name of the function.</li><li>Arguments are values a function receives when it is invoked.</li><li>When the control reaches the return statement, js will stop executing and the value is returned to the caller.</li></ul>



<p class="wp-block-paragraph"><strong>There are three steps of Functions as well as Methods to use in the program.</strong></p>



<ol class="wp-block-list"><li><strong>Declaration</strong></li><li><strong>Definition.</strong></li><li><strong>Call</strong></li></ol>



<p class="wp-block-paragraph">In JavaScript function <em>declaration </em>and <em>definition </em>are mostly done together.</p>



<p class="wp-block-paragraph">A JavaScript <strong>method </strong>is a property of an object that contains a function definition. Methods are functions stored as object properties.</p>



<p class="wp-block-paragraph"><strong>Few Important things of Methods:-</strong></p>



<ul class="wp-block-list"><li>In JavaScript, however, a <em>method</em> is a <strong>function</strong> that belongs to an <strong><em>object</em></strong>.</li><li>JavaScript <strong>methods </strong>are the actions that can be performed on objects. </li><li>A JavaScript <strong>method</strong> is a property containing a <strong>function definition</strong>. </li><li>Accessing the object method is done with the following syntax: <em>objectName.methodName()</em></li></ul>



<p class="wp-block-paragraph"><strong>Syntax of Function</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
var func = function(a, b) {
    var sum = a + b;
    return sum;
}
  
console.log(sum(1, 2));
</pre></div>


<p class="wp-block-paragraph"><strong>Syntax of Methods</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
object = {
    methodName: function() {
        // Content
    }
};

object.methodName()
</pre></div>


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Few important links for learning:-</strong></p>



<ol class="wp-block-list"><li>Let’s see an example for User form validation in JavaScript. click <a rel="noreferrer noopener" href="https://www.scmgalaxy.com/tutorials/registration-form-validation-using-javascript/" target="_blank">here</a>.</li><li>Let’s understand JavaScript. what and how? click <a rel="noreferrer noopener" href="https://www.scmgalaxy.com/tutorials/a-brief-description-of-javascript/" target="_blank">here</a>.</li><li>Want to know what is <strong>function</strong> and how to use them in JavaScript? Just click <a rel="noreferrer noopener" href="https://www.scmgalaxy.com/tutorials/function-in-javascript/" target="_blank">here</a>.</li><li>Want to know what are <strong>variables </strong>and how to use them in JavaScript? Just click <a rel="noreferrer noopener" href="https://www.scmgalaxy.com/tutorials/variables-in-javascript-var-let-const/" target="_blank">here</a>.</li></ol>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/difference-between-function-and-method-in-javascript/">Difference between Function and Method 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/difference-between-function-and-method-in-javascript/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Predefined Functions in JavaScript</title>
		<link>https://www.scmgalaxy.com/tutorials/predefined-functions-in-javascript/</link>
					<comments>https://www.scmgalaxy.com/tutorials/predefined-functions-in-javascript/#respond</comments>
		
		<dc:creator><![CDATA[abhishek k]]></dc:creator>
		<pubDate>Thu, 25 Mar 2021 07:05:05 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[functions in javascript]]></category>
		<category><![CDATA[javascript function]]></category>
		<category><![CDATA[javascript function predefined]]></category>
		<category><![CDATA[Predefined Functions]]></category>
		<category><![CDATA[Predefined Functions in JavaScript]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=5742</guid>

					<description><![CDATA[<p>Want to know what is function and how to use them in JavaScript? Just click here. Every computer programming language [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/predefined-functions-in-javascript/">Predefined Functions in JavaScript</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Want to know what is function and how to use them in JavaScript? Just click <a href="https://www.scmgalaxy.com/tutorials/function-in-javascript/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p class="wp-block-paragraph">Every computer programming language has functions. Some functions are defined by the programmers while the code is being written while some functions are predefined when the language was built.</p>



<p class="wp-block-paragraph"><strong>As every functions have three parts </strong></p>



<ol class="wp-block-list" id="block-846515e5-02b2-42ea-8c13-e4eb7eeb82ff"><li><strong>Function Declaration</strong></li><li><strong>Function</strong> <strong>Definition.</strong></li><li><strong>Function</strong> <strong>Call</strong></li></ol>



<p class="wp-block-paragraph">In predefined functions, the first two points are already done inside the library which we include as a header file at the beginning of the program. <strong>we just have to call the function.</strong></p>



<p class="wp-block-paragraph">Few most common predefined functions that we use are:-</p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Functions to display something in JavaScript:- </strong></p>



<p class="wp-block-paragraph"><strong>alert(</strong>message<strong>) </strong>– It displays an alert box with a message specified in it.</p>



<p class="wp-block-paragraph"><strong>confirm</strong>(message) – It will display the message with two buttons. “OK” and “Cancel”.</p>



<p class="wp-block-paragraph"><strong>prompt</strong>(message) – Displays a box with the message passed. There the user can enter text in the prompt field, and choose OK or Cancel. If the user chooses OK, the string value entered in the field is returned and If the user chooses Cancel, a NULL value is returned.</p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Functions for conversion in JavaScript:-</strong></p>



<p class="wp-block-paragraph"><strong>parseFloat</strong>() – It returns floating-point numbers the same way as the parseInt function does, but looks for floating-point qualified strings and returns their value as afloat.</p>



<p class="wp-block-paragraph"><strong>parseInt</strong>()– It converts a string to an integer returning the first integer encountered which is contained in the string. If no integer values are found such as in the string “written text”, then a value of 0 is returned.</p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Functions for comparison in JavaScript:-</strong></p>



<p class="wp-block-paragraph"><strong>eval</strong>()– Converts a string to integer or float value.</p>



<p class="wp-block-paragraph"><strong>isNaN</strong>(value) – If the value passed is not a number, the boolean value of true is returned, if it is a number, it returns false.</p>



<p class="wp-block-paragraph"><strong>escape</strong>(string) – It passes the string to be encoded and returns the encoded string. Encodes a string from ASCII into an ISO Latin-1 (ISO 8859-1) character set for HTML processing. </p>



<p class="wp-block-paragraph"><strong>unescape() </strong>– Converts an ISO8859-1 character set to ASCII. </p>



<p class="wp-block-paragraph"><strong>isFinite()</strong> &#8211; function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.</p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Functions for decoding and encoding in JavaScript:-</strong></p>



<p class="wp-block-paragraph"><code><strong>decodeURI()</strong></code> function decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine. <em>decodeURIComponent</em>()</p>



<p class="wp-block-paragraph"><code><strong>decodeURIComponent()</strong></code> method decodes a Uniform Resource Identifier (URI) component previously created by <em>encodeURIComponent</em><strong>()</strong> or by a similar routine. encodeURI</p>



<p class="wp-block-paragraph"><code><strong>encodeURI()</strong></code> encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two &#8220;surrogate&#8221; characters). <em>encodeURIComponent</em>()</p>



<p class="wp-block-paragraph"><code>e<strong>ncodeURIComponent()</strong></code> encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two &#8220;surrogate&#8221; characters).</p>



<p class="wp-block-paragraph">There are more predefined functions but these were the important ones which are often used.</p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Few important links for learning:-</strong></p>



<ol class="wp-block-list"><li>Let&#8217;s see an example for User form validation in JavaScript. click <a href="https://www.scmgalaxy.com/tutorials/registration-form-validation-using-javascript/" target="_blank" rel="noreferrer noopener">here</a>.</li><li>Let&#8217;s understand javascript. what and how? click <a rel="noreferrer noopener" href="https://www.scmgalaxy.com/tutorials/a-brief-description-of-javascript/" target="_blank">here</a>.</li><li>Want to know what is <strong>function</strong> and how to use them in JavaScript? Just click <a rel="noreferrer noopener" href="https://www.scmgalaxy.com/tutorials/function-in-javascript/" target="_blank">here</a>.</li><li>Want to know what are <strong>variables </strong>and how to use them in JavaScript? Just click <a rel="noreferrer noopener" href="https://www.scmgalaxy.com/tutorials/variables-in-javascript-var-let-const/" target="_blank">here</a>. </li></ol>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/predefined-functions-in-javascript/">Predefined Functions 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/predefined-functions-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
