{"id":1019,"date":"2021-12-12T07:32:29","date_gmt":"2021-12-12T07:32:29","guid":{"rendered":"https:\/\/swatilathia.wordpress.com\/?page_id=1019"},"modified":"2024-12-18T05:26:04","modified_gmt":"2024-12-18T05:26:04","slug":"javascript-tutorial-3-built-in-functions","status":"publish","type":"page","link":"https:\/\/swatilathia.com\/?page_id=1019","title":{"rendered":"JavaScript Tutorial 3 &#8211; Built In Functions"},"content":{"rendered":"<body>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e1f3c3455b1\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e1f3c3455b1\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/swatilathia.com\/?page_id=1019\/#String_Functions\" >String Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/swatilathia.com\/?page_id=1019\/#Math_Functions\" >Math Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/swatilathia.com\/?page_id=1019\/#Array_Functions\" >Array Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/swatilathia.com\/?page_id=1019\/#Date_Functions\" >Date Functions<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"sf\"><span class=\"ez-toc-section\" id=\"String_Functions\"><\/span><strong>String Functions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>charAt()<\/strong><\/li>\n\n\n\n<li>It is a method that returns the character from the specified index.<\/li>\n\n\n\n<li>Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character in a string, called stringName, is stringName.length \u2013 1.<\/li>\n\n\n\n<li><strong>Syntax: <\/strong>string.charAt(index);<\/li>\n\n\n\n<li>index \u2212 An integer between 0 and 1 less than the length of the string.<\/li>\n\n\n\n<li><strong>Return Value: <\/strong>Returns the character from the specified index.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;body&gt;  \n      \t &lt;script type = \"text\/javascript\"&gt;\n         var str = new String( \"This is string\" );\n         document.writeln(\"str.charAt(0) is:\"+str.charAt(0)); \n         document.writeln(\"&lt;br&gt;str.charAt(1) is:\"+str.charAt(1)); \n         document.writeln(\"&lt;br&gt;str.charAt(2) is:\"+str.charAt(2)); \n         document.writeln(\"&lt;br&gt;str.charAt(3) is:\"+str.charAt(3)); \n         document.writeln(\"&lt;br&gt;str.charAt(4) is:\"+str.charAt(4)); \n         document.writeln(\"&lt;br&gt;str.charAt(5) is:\"+str.charAt(5)); \n         &lt;\/script&gt;      \n&lt;\/body&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>charCodeAt()<\/strong><\/li>\n\n\n\n<li>This method returns a number indicating the Unicode value of the character at the given index.<\/li>\n\n\n\n<li>Unicode code points range from 0 to 1,114,111. The first 128 Unicode code points are a direct match of the ASCII character encoding. charCodeAt() always returns a value that is less than 65,536.<\/li>\n\n\n\n<li><strong>Syntax: <\/strong>string.charCodeAt(index);<\/li>\n\n\n\n<li><strong>index \u2212 <\/strong>An integer between 0 and 1 less than the length of the string; if unspecified, defaults to 0.<\/li>\n\n\n\n<li><strong>Return Value: <\/strong>Returns a number indicating the Unicode value of the character at the given index. It returns NaN if the given index is not between 0 and 1 less than the length of the string.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;body&gt;  \n\t&lt;script type = \"text\/javascript\"&gt;\n         var str = new String(\"Bhavan's H J Doshi Jamnagar\");\n         document.writeln(str.charCodeAt(0)); \n         document.writeln(\"&lt;br&gt;\"+ str.charCodeAt(1)); \n         document.writeln(\"&lt;br&gt;\" + str.charCodeAt(2)); \n         document.writeln(\"&lt;br&gt;\" + str.charCodeAt(3)); \n         document.writeln(\"&lt;br&gt;\" + str.charCodeAt(4)); \n         document.writeln(\"&lt;br&gt;\" + str.charCodeAt(5)); \n         &lt;\/script&gt;      \n&lt;\/body&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>concat()<\/strong><\/li>\n\n\n\n<li>This method adds two or more strings and returns a new single string. <\/li>\n\n\n\n<li>Syntax: string.concat(string2, string3, \u2026,stringN);<\/li>\n\n\n\n<li><strong>String2\u2026stringN<\/strong> \u2212 These are the strings to be concatenated.<\/li>\n\n\n\n<li><strong>Return Value<\/strong>: Returns a single concatenated string.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\nvar str1 = new String( \"This is string one\" );\nvar str2 = new String( \" This is string two\" );\nvar str3 = str1.concat(str2);      \ndocument.write(\"Concatenated String :\" + str3); \n&lt;\/script&gt;   \n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>indexOf()<\/strong><\/li>\n\n\n\n<li>This method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex or -1 if the value is not found.<\/li>\n\n\n\n<li>Syntax: string.indexOf(searchValue[, fromIndex])<\/li>\n\n\n\n<li><strong>searchValue<\/strong> \u2212 A string representing the value to search for.<\/li>\n\n\n\n<li><strong>fromIndex<\/strong> \u2212 The location within the calling string to start the search from. It can be any integer between 0 and the length of the string. The default value is 0.<\/li>\n\n\n\n<li><strong>Return Value: <\/strong>Returns the index of the found occurrence, otherwise -1 if not found.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n      var str1 = new String( \"This is HJDoshi\" );\n      var index = str1.indexOf(\"is\");\n      document.write(\"indexOf found String :\" + index ); \n      document.write(\"&lt;br&gt;\");\n      var index = str1.indexOf(\"Doshi\");\n      document.write(\"indexOf found String :\" + index ); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>lastIndexOf()<\/strong><\/li>\n\n\n\n<li>This method returns the index within the calling String object of the last occurrence of the specified value, starting the search at fromIndex or -1 if the value is not found.<\/li>\n\n\n\n<li>Syntax: string.lastIndexOf(searchValue[, fromIndex])<\/li>\n\n\n\n<li><strong>searchValue<\/strong> \u2212 A string representing the value to search for.<\/li>\n\n\n\n<li><strong>fromIndex<\/strong> \u2212 The location within the calling string to start the search from. It can be any integer between 0 and the length of the string. The default value is 0.<\/li>\n\n\n\n<li><strong>Return Value<\/strong>: Returns the index of the last found occurrence, otherwise -1 if not found.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n        var str1 = new String( \"This is HJDoshi\" );\n        var index = str1.lastIndexOf(\"is\");\n        document.write(\"indexOf found String :\" + index ); \n        document.write(\"&lt;br&gt;\");\n        var index = str1.lastIndexOf(\"Doshi\");\n        document.write(\"indexOf found String :\" + index ); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>slice()<\/strong><\/li>\n\n\n\n<li>This method extracts a section of a string and returns a new string.<\/li>\n\n\n\n<li><strong>Syntax: <\/strong>string.slice( beginslice [, endSlice] );<\/li>\n\n\n\n<li><strong>beginSlice<\/strong> \u2212 The zero-based index at which to begin extraction.<\/li>\n\n\n\n<li><strong>endSlice<\/strong> \u2212 The zero-based index at which to end extraction. If omitted, slice extracts to the end of the string.<\/li>\n\n\n\n<li><strong>Return Value:<\/strong> If successful, slice returns the index of the regular expression inside the string. Otherwise, it returns -1.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n\tvar str1 = new String(\"This is HJDoshi\");\n\tdocument.write(str1.slice(-7,-1)); \n&lt;\/script&gt;  <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>split()<\/strong><\/li>\n\n\n\n<li>This method splits a String object into an array of strings by separating the string into substrings.<\/li>\n\n\n\n<li>Syntax: string.split([separator][, limit]);<\/li>\n\n\n\n<li><strong>separator<\/strong> \u2212 Specifies the character to use for separating the string. If separator is omitted, the array returned contains one element consisting of the entire string.<\/li>\n\n\n\n<li><strong>limit<\/strong> \u2212 Integer specifying a limit on the number of splits to be found.<\/li>\n\n\n\n<li><strong>Return Value: <\/strong>The split method returns the new array. Also, when the string is empty, split returns an array containing one empty string, rather than an empty array.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         var str1 = new String(\"This is HJDoshi\");\n         document.write(str1.split(\" \",3)); \n&lt;\/script&gt;  <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>toLowerCase()<\/strong><\/li>\n\n\n\n<li>This method returns the calling string value converted to lowercase.<\/li>\n\n\n\n<li><strong>Syntax: <\/strong>string.toLowerCase( )<\/li>\n\n\n\n<li><strong>Return Value<\/strong>: Returns the calling string value converted to lowercase.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n      \t\tvar str1 = new String(\"This is HJDoshi\");\n      \t\tdocument.write(str1.toLowerCase()); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>toUpperCase()<\/strong><\/li>\n\n\n\n<li>This method returns the calling string value converted to uppercase.<\/li>\n\n\n\n<li><strong>Syntax: <\/strong>string.toUpperCase( )<\/li>\n\n\n\n<li><strong>Return Value: <\/strong>Returns a string representing the specified object.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         \tvar str1 = new String(\"This is HJDoshi\");\n          \tdocument.write(str1.toUpperCase()); \n&lt;\/script&gt;  <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"mf\"><span class=\"ez-toc-section\" id=\"Math_Functions\"><\/span><strong>Math Functions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>abs()<\/strong><\/li>\n\n\n\n<li>This method returns the absolute value of a number.<\/li>\n\n\n\n<li><strong>Syntax:<\/strong> Math.abs( x ) ;<\/li>\n\n\n\n<li><strong>x \u2212<\/strong> A number<\/li>\n\n\n\n<li><strong>Return Value: <\/strong>Returns the absolute value of a number.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         var a = Math.abs(-10);\n          document.write(a); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>ceil()<\/strong><\/li>\n\n\n\n<li>This method returns the smallest integer greater than or equal to a number.<\/li>\n\n\n\n<li><strong>Syntax:<\/strong> Math.ceil( x ) ;<\/li>\n\n\n\n<li><strong>x \u2212<\/strong> A numbers.<\/li>\n\n\n\n<li><strong>Return Value<\/strong>: Returns the smallest integer greater than or equal to a number.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         \t\tvar a = Math.ceil(-4.3);\n          \t\tdocument.write(a); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>floor()<\/strong><\/li>\n\n\n\n<li>This method returns the largest integer less than or equal to a number.<\/li>\n\n\n\n<li>Syntax: Math.floor( x ) ;<\/li>\n\n\n\n<li>x \u2212 A numbers.<\/li>\n\n\n\n<li><strong>Return Value:<\/strong> Returns the largest integer less than or equal to a number x.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         \t\tvar a = Math.floor(-4.3);\n          \t\tdocument.write(a); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>log()<\/strong><\/li>\n\n\n\n<li>This method returns the natural logarithm (base E) of a number. If the value of number is negative, the return value is always NaN.<\/li>\n\n\n\n<li>Syntax: Math.log( x ) ;<\/li>\n\n\n\n<li>x \u2212 A numbers.<\/li>\n\n\n\n<li><strong>Return Value:<\/strong> Returns the natural logarithm (base E) of a number.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         \t\tvar a = Math.log(10);\n          \t\tdocument.write(a); \n&lt;\/script&gt;  <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>max()<\/strong><\/li>\n\n\n\n<li>This method returns the largest of zero or more numbers. If no arguments are given, the results is \u2013Infinity.<\/li>\n\n\n\n<li>Syntax: Math.max(value1, value2, \u2026 valueN ) ;<\/li>\n\n\n\n<li>value1, value2, \u2026 valueN : Numbers.<\/li>\n\n\n\n<li><strong>Return Value:<\/strong> Returns the largest of zero or more numbers.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         \t\tvar a = Math.max(10,-3,0,200);\n          \t\tdocument.write(a); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>min()<\/strong><\/li>\n\n\n\n<li>This method returns the smallest of zero or more numbers. If no arguments are given, the results is +Infinity.<\/li>\n\n\n\n<li>Syntax: Math.min(value1, value2, \u2026 valueN ) ;<\/li>\n\n\n\n<li>value1, value2, \u2026 valueN : Numbers.<\/li>\n\n\n\n<li>Return Value: Returns the smallest of zero or more numbers.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         \t\tvar a = Math.min(10,-3,0,200);\n          \t\tdocument.write(a); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>pow()<\/strong><\/li>\n\n\n\n<li>This method returns the base to the exponent power, that is, baseexponent.<\/li>\n\n\n\n<li>Syntax: Math.pow(base, exponent ) ;<\/li>\n\n\n\n<li>base \u2212 The base number.<\/li>\n\n\n\n<li>exponents \u2212 The exponent to which to raise base.<\/li>\n\n\n\n<li><strong>Return Value:<\/strong> Returns the base to the exponent power, that is, base exponent.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         \t\tvar a = Math.pow(7,3);\n          \t\tdocument.write(a); \n&lt;\/script&gt;  <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>random()<\/strong><\/li>\n\n\n\n<li>This method returns a random number between 0 (inclusive) and 1 (exclusive).<\/li>\n\n\n\n<li>Syntax: Math.random() ;<\/li>\n\n\n\n<li><strong>Return Value:<\/strong> Returns a random number between 0 (inclusive) and 1 (exclusive).<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         var a = Math.random();\n         document.write(a); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>round()<\/strong><\/li>\n\n\n\n<li>This method returns the value of a number rounded to the nearest integer.<\/li>\n\n\n\n<li>Syntax: Math.round( x ) ;<\/li>\n\n\n\n<li>Return Value: Returns the value of a number rounded to the nearest integer.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n          var a = Math.round(-20.3);\n          document.write(a); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>sqrt()<\/strong><\/li>\n\n\n\n<li>This method returns the square root of a number. If the value of a number is negative, sqrt returns NaN.<\/li>\n\n\n\n<li>Syntax: Math.sqrt( x ) ;<\/li>\n\n\n\n<li>x \u2212 A number<\/li>\n\n\n\n<li>Return Value: Returns the square root of a given number.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n         \t\tvar a = Math.sqrt(100);\n          \t\tdocument.write(a); \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"af\"><span class=\"ez-toc-section\" id=\"Array_Functions\"><\/span><strong>Array Functions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>concat()<\/strong><\/li>\n\n\n\n<li>It combines two or more arrays and returns a new string. This method doesn\u2019t make any change in the original array.<\/li>\n\n\n\n<li>Syntax: array.concat(arr1,arr2,\u2026.,arrn)\u00a0<\/li>\n\n\n\n<li>arr1,arr2,\u2026.,arrn \u2013 It represent the arrays to be combined.<\/li>\n\n\n\n<li><strong>Return<\/strong>: A new array object that represents a joined array.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n       \t\t var arr1=[\"C\",\"C++\",\"Python\"];  \n\t     \t var arr2=[\"Java\",\"JavaScript\",\"Android\"];  \n\t\t var result=arr1.concat(arr2);  \n\t\t document.write(result);  \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>join()<\/strong><\/li>\n\n\n\n<li>It combines all the elements of an array into a string and return a new string. We can use any type of separators to separate given array elements.<\/li>\n\n\n\n<li>Syntax: array.join(separator)\u00a0<\/li>\n\n\n\n<li>Separator() \u2013 It is optional. It represents the separator used between array elements.<\/li>\n\n\n\n<li>Return: A new string contains the array values with specified separator.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n       \t\tvar arr1=[\"C\",\"C++\",\"Python\"];  \n\t\tvar result=arr1.join();  \n\t\tdocument.write(result);  \n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>pop()<\/strong><\/li>\n\n\n\n<li>It removes the last element from the given array and return that element. This method changes the length of the original array.<\/li>\n\n\n\n<li><strong>Syntax<\/strong>: array.pop()\u00a0 <\/li>\n\n\n\n<li><strong>Return<\/strong>: The last element of given array.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n       \tvar arr1=[\"C\",\"C++\",\"Python\"];  \n\t\tvar result=arr1.pop();  \n\t\tdocument.write(\"The deleted element = \",result,\"&lt;br&gt;\"); \n\t\tdocument.write(\"Now the new array  = \",arr1);\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>push()<\/strong><\/li>\n\n\n\n<li>It adds one or more elements to the end of the given array. This method changes the length of the original array.<\/li>\n\n\n\n<li><strong>Syntax<\/strong>: array.push(element1,element2\u2026.elementn)\u00a0<\/li>\n\n\n\n<li>element1,element2\u2026.elementn \u2013 The elements to be added. <\/li>\n\n\n\n<li><strong>Return:<\/strong> The original array with added elements.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n        var arr1=[\"C\",\"C++\",\"Python\"];  \n\tvar result=arr1.push(\"Java\",\"JavaScript\");  \n\tdocument.write(\"The new length of an array = \",result,\"&lt;br&gt;\");\n\tdocument.write(\"Now the new array = \",arr1);\n&lt;\/script&gt;  <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>shift()<\/strong><\/li>\n\n\n\n<li>It removes the first element of the given array and returns that element. This method changes the length of the original array.<\/li>\n\n\n\n<li><strong>Syntax<\/strong>: array. shift()\u00a0<\/li>\n\n\n\n<li><strong>Return<\/strong>: The first element of an array.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n        var arr1=[\"C\",\"C++\",\"Python\"];  \n\tvar result=arr1.shift();  \n\tdocument.write(\"The deleted element  = \",result,\"&lt;br&gt;\");\n\tdocument.write(\"Now the array = \",arr1);\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>unshift()<\/strong><\/li>\n\n\n\n<li>It adds one or more elements to the beginning of an array.<\/li>\n\n\n\n<li><strong>Syntax<\/strong>: array.unshift()\u00a0<\/li>\n\n\n\n<li><strong>Return<\/strong>: The new length of an array.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script type = \"text\/javascript\"&gt;\n        var arr1=[\"C\",\"C++\",\"Python\"];  \n\tvar result=arr1.unshift(\"ASP.net\",\"Java\");  \n\tdocument.write(\"The length of an array = \",result,\"&lt;br&gt;\");\n\tdocument.write(\"Now the new array = \",arr1);\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"df\"><span class=\"ez-toc-section\" id=\"Date_Functions\"><\/span><strong>Date Functions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">The JavaScript date object can be used to get year, month and day.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>getDate()<\/strong><\/li>\n\n\n\n<li>This method returns the day for the specified date on the basis of local time.<\/li>\n\n\n\n<li><strong>Syntax: <\/strong>dateObj.getDate()<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>getDay()<\/strong><\/li>\n\n\n\n<li>This method returns the value of day of the week for the specified date on the basis of local time. The value of the day starts with 0 that represents Sunday.<\/li>\n\n\n\n<li><strong>Syntax:<\/strong> dateObj.getDay()\u00a0<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>getFullYear()<\/strong><\/li>\n\n\n\n<li>This method returns the year for the specified date on the basis of universal time.<\/li>\n\n\n\n<li><strong>Syntax:<\/strong> dateObj.getFullYear()<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>getMonth()<\/strong><\/li>\n\n\n\n<li>This method returns the integer value that represents month in the specified date on the basis of local time. The value returned by getMonth() method starts with 0 that represents January.<\/li>\n\n\n\n<li><strong>Syntax:<\/strong> dateObj.getMonth()\u00a0<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>getHours()<\/strong><\/li>\n\n\n\n<li>This method returns the hour for the specified date on the basis of local time.<\/li>\n\n\n\n<li><strong>Syntax: <\/strong>dateObj.getHours()\u00a0<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>getMinutes()<\/strong><\/li>\n\n\n\n<li>This method returns the minutes in the specified date on the basis of local time.<\/li>\n\n\n\n<li><strong>Syntax:<\/strong> dateObj.getMinutes()\u00a0<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>getSeconds()<\/strong><\/li>\n\n\n\n<li>This method returns the seconds in the specified date on the basis of local time.<\/li>\n\n\n\n<li><strong>Syntax:<\/strong> dateObj.getSeconds()\u00a0<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list has-medium-font-size\">\n<li><strong>getMilliseconds()<\/strong><\/li>\n\n\n\n<li>This method returns the value of milliseconds in specified date on the basis of local time.<\/li>\n\n\n\n<li><strong>Syntax:<\/strong> dateObj.getMilliseconds()\u00a0<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>&lt;script language=\"javascript\"&gt;  \n          var dt=new Date();  \n          document.write(dt);\n          document.write(\"Today's date \".dt.getDate());  \n          document.write(\"Today is \".dt.getDay());  \n          document.write(\"Current Year is \".dt.getFullYear());  \n          document.write(\"Current Month is \".dt.getMonth());\n          document.write(\"Current Hour is \".dt.getHours()); \n          document.write(\"Current Minute is \".dt.getMinutes());\n          document.write(\"Current Second is \".dt.getSeconds()); \n          document.write(\"Current millisecond is \".dt.getMilliseconds());\n&lt;\/script&gt;<\/code><\/pre>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>String Functions Math Functions Array Functions Date Functions<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"om_disable_all_campaigns":false,"footnotes":""},"class_list":["post-1019","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/swatilathia.com\/index.php?rest_route=\/wp\/v2\/pages\/1019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swatilathia.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/swatilathia.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/swatilathia.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/swatilathia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1019"}],"version-history":[{"count":4,"href":"https:\/\/swatilathia.com\/index.php?rest_route=\/wp\/v2\/pages\/1019\/revisions"}],"predecessor-version":[{"id":5613,"href":"https:\/\/swatilathia.com\/index.php?rest_route=\/wp\/v2\/pages\/1019\/revisions\/5613"}],"wp:attachment":[{"href":"https:\/\/swatilathia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}