{"id":5742,"date":"2021-03-25T07:05:05","date_gmt":"2021-03-25T07:05:05","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=5742"},"modified":"2021-03-25T07:05:05","modified_gmt":"2021-03-25T07:05:05","slug":"predefined-functions-in-javascript","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/","title":{"rendered":"Predefined Functions in JavaScript"},"content":{"rendered":"\n<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>\n\n\n\n<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>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>As every functions have three parts <\/strong><\/p>\n\n\n\n<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>\n\n\n\n<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>\n\n\n\n<p class=\"wp-block-paragraph\">Few most common predefined functions that we use are:-<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Functions to display something in JavaScript:- <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>alert(<\/strong>message<strong>)\u00a0<\/strong>\u2013 It displays an alert box with a message specified in it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>confirm<\/strong>(message)\u00a0\u2013 It will display the message with two buttons. \u201cOK\u201d and \u201cCancel\u201d.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>prompt<\/strong>(message)\u00a0\u2013 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>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Functions for conversion in JavaScript:-<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>parseFloat<\/strong>()\u00a0\u2013 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>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>parseInt<\/strong>()\u2013 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 \u201cwritten text\u201d, then a value of 0 is returned.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Functions for comparison in JavaScript:-<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>eval<\/strong>()\u2013 Converts a string to integer or float value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>isNaN<\/strong>(value)\u00a0\u2013 If the value passed is not a number, the boolean value of true is returned, if it is a number, it returns false.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>escape<\/strong>(string)\u00a0\u2013 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>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>unescape()\u00a0<\/strong>\u2013 Converts an ISO8859-1 character set to ASCII. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>isFinite()<\/strong> &#8211;\u00a0function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Functions for decoding and encoding in JavaScript:-<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code><strong>decodeURI()<\/strong><\/code>\u00a0function decodes a Uniform Resource Identifier (URI) previously created by\u00a0encodeURI or by a similar routine. <em>decodeURIComponent<\/em>()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code><strong>decodeURIComponent()<\/strong><\/code>\u00a0method decodes a Uniform Resource Identifier (URI) component previously created by\u00a0<em>encodeURIComponent<\/em><strong>()<\/strong>\u00a0or by a similar routine. encodeURI<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code><strong>encodeURI()<\/strong><\/code>\u00a0encodes 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>\n\n\n\n<p class=\"wp-block-paragraph\"><code>e<strong>ncodeURIComponent()<\/strong><\/code>\u00a0encodes 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>\n\n\n\n<p class=\"wp-block-paragraph\">There are more predefined functions but these were the important ones which are often used.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Few important links for learning:-<\/strong><\/p>\n\n\n\n<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>\n","protected":false},"excerpt":{"rendered":"<p>Want to know what is function and how to use them in JavaScript? Just click here. Every computer programming language [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[16,156],"tags":[5166,5143,5167,5164,5165],"class_list":["post-5742","post","type-post","status-publish","format-standard","hentry","category-javascript","category-websites","tag-functions-in-javascript","tag-javascript-function","tag-javascript-function-predefined","tag-predefined-functions","tag-predefined-functions-in-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Predefined Functions in JavaScript - scmGalaxy<\/title>\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.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Predefined Functions in JavaScript - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Want to know what is function and how to use them in JavaScript? Just click here. Every computer programming language [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-25T07:05:05+00:00\" \/>\n<meta name=\"author\" content=\"abhishek k\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"abhishek k\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/\"},\"author\":{\"name\":\"abhishek k\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/143500a93b88a96d3c9602b3df804cb6\"},\"headline\":\"Predefined Functions in JavaScript\",\"datePublished\":\"2021-03-25T07:05:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/\"},\"wordCount\":558,\"commentCount\":0,\"keywords\":[\"functions in javascript\",\"javascript function\",\"javascript function predefined\",\"Predefined Functions\",\"Predefined Functions in JavaScript\"],\"articleSection\":[\"JavaScript\",\"Websites\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/\",\"name\":\"Predefined Functions in JavaScript - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2021-03-25T07:05:05+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/143500a93b88a96d3c9602b3df804cb6\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/predefined-functions-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Predefined Functions in JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/143500a93b88a96d3c9602b3df804cb6\",\"name\":\"abhishek k\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7e05a074cc5eeb0b13b5768bbfd8f7793851f739965234dc5aaae590b9c8677f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7e05a074cc5eeb0b13b5768bbfd8f7793851f739965234dc5aaae590b9c8677f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7e05a074cc5eeb0b13b5768bbfd8f7793851f739965234dc5aaae590b9c8677f?s=96&d=mm&r=g\",\"caption\":\"abhishek k\"},\"description\":\"Abhishek is a full-stack developer that provides the solution for the design and analysis of Website and Mobile Application. Expertise in HTML, CSS, JAVASCRIPT, LARAVEL.\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/abhishek\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Predefined Functions in JavaScript - scmGalaxy","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.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Predefined Functions in JavaScript - scmGalaxy","og_description":"Want to know what is function and how to use them in JavaScript? Just click here. Every computer programming language [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/","og_site_name":"scmGalaxy","article_published_time":"2021-03-25T07:05:05+00:00","author":"abhishek k","twitter_card":"summary_large_image","twitter_misc":{"Written by":"abhishek k","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/"},"author":{"name":"abhishek k","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/143500a93b88a96d3c9602b3df804cb6"},"headline":"Predefined Functions in JavaScript","datePublished":"2021-03-25T07:05:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/"},"wordCount":558,"commentCount":0,"keywords":["functions in javascript","javascript function","javascript function predefined","Predefined Functions","Predefined Functions in JavaScript"],"articleSection":["JavaScript","Websites"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/","name":"Predefined Functions in JavaScript - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2021-03-25T07:05:05+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/143500a93b88a96d3c9602b3df804cb6"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/predefined-functions-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Predefined Functions in JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/143500a93b88a96d3c9602b3df804cb6","name":"abhishek k","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/7e05a074cc5eeb0b13b5768bbfd8f7793851f739965234dc5aaae590b9c8677f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7e05a074cc5eeb0b13b5768bbfd8f7793851f739965234dc5aaae590b9c8677f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7e05a074cc5eeb0b13b5768bbfd8f7793851f739965234dc5aaae590b9c8677f?s=96&d=mm&r=g","caption":"abhishek k"},"description":"Abhishek is a full-stack developer that provides the solution for the design and analysis of Website and Mobile Application. Expertise in HTML, CSS, JAVASCRIPT, LARAVEL.","url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/abhishek\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=5742"}],"version-history":[{"count":2,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5742\/revisions"}],"predecessor-version":[{"id":5765,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5742\/revisions\/5765"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=5742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=5742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=5742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}