{"id":7442,"date":"2021-08-05T11:38:40","date_gmt":"2021-08-05T11:38:40","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=7442"},"modified":"2022-04-13T16:30:46","modified_gmt":"2022-04-13T16:30:46","slug":"how-to-use-number-methods-in-javascript","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/","title":{"rendered":"How to use Number Methods in JavaScript?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Number Methods<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>toString ( )<\/strong><\/li><li><strong>toExponential ( )<\/strong><\/li><li><strong>toFixed ( )<\/strong><\/li><li><strong>toPrecision ( )<\/strong><\/li><li><strong>valueOf( )<\/strong><\/li><li><strong>isFinite( )<\/strong><\/li><li><strong>isInteger( )<\/strong><\/li><li><strong>isNan( )<\/strong><\/li><li><strong>isSafeInteger( )<\/strong><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">toString( )<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">toString ( ) method returns a number as a string in other words it converts a number into a string. We can use this method to output numbers as hexadecimal (16), octal(8), binary(2).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax: &#8211;<br>Variable_name.toString( );<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/f1fc0a684e12220197b9ce3abcc7cc69.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">toExponential ( )<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The toExponential() method converts a number into an exponential notation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax:-<br>Variable_name.toExponential(y)<br>Where y is an integer between 0 and 20 representing the number of digits in the<br>notation after the decimal point. If omitted, it is set to as many digits as necessary to<br>represent the value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ex: &#8211;<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/690db0ff3ba7194c2770fd51dfd354eb.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">toFixed ( )<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The toFixed() method converts a number into a string, keeping a specified number of decimals also rounds the decimal. If the desired number of decimals is higher than the actual number, nulls are added to create the desired decimal length.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax: &#8211;<br>a.toFixed(y)<br>Where y is the number of digits after the decimal point. Default is 0 (no digits after the decimal point)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax: &#8211;<br>a.toFixed(y)<br>Where y is the number of digits after the decimal point. Default is 0 (no digits after the decimal point)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/75571b15d69e97a04ddbf28799af5dae.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">toPrecision ( )<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The toPrecision() method formats a number to a specified length.<br>A decimal point and nulls are added (if needed), to create the specified length.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax:-<br>Variable_name.toPrecision(y)<br>Where y is the number of digits. If omitted, it returns the entire number (without any<br>formatting)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax:-<br>Variable_name.toPrecision(y)<br>Where y is the number of digits. If omitted, it returns the entire number (without any<br>formatting)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ex:-<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/e35753fc561a64f68f1d93ab8b86e882.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Number.isNaN()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>Number.isNaN() <\/strong>method determines whether a value is NaN (Not-A-Number).<br>This method returns true if the value is of the type Number, and equates to NaN. Otherwise, it returns false.<br>Number.isNaN() is different from the global isNaN() function. The global isNaN() function<br>converts the tested value to a Number, then tests it.<br>Number.isNaN() does not convert the values to a Number, and will not return true for any value<br>that is not of the type Number.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/16f8fc3f9eba2e7e18df23951e82f852.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Number.isInteger( )<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Number.isInteger() method determines whether a value is an integer.<br>This method returns true if the value is of the type Number, and an integer, otherwise it<br>returns false.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ex: &#8211;<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/ad493b00cbc323e47e0f38adf4143e5d.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Number.isSafeInteger()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Number.isSafeInteger() method determines whether a value is a safe integer.<br>A safe integer is an integer that can be exactly all integers from (2^53 &#8211; 1) to -(2^53 &#8211; 1)<br>This method returns true if the value is of the type Number and a safe integer.<br>Otherwise, it returns false.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/f3532004826a3db95488ecdd8eab380c.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>Number Methods toString ( ) toExponential ( ) toFixed ( ) toPrecision ( ) valueOf( ) isFinite( ) isInteger( ) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[16],"tags":[5095,5176,5955,5045],"class_list":["post-7442","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript","tag-methods-in-javascript","tag-tostring","tag-variable"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to use Number Methods 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\/how-to-use-number-methods-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use Number Methods in JavaScript? - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Number Methods toString ( ) toExponential ( ) toFixed ( ) toPrecision ( ) valueOf( ) isFinite( ) isInteger( ) [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-05T11:38:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-13T16:30:46+00:00\" \/>\n<meta name=\"author\" content=\"rajeshkumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rajeshkumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/\"},\"author\":{\"name\":\"rajeshkumar\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"headline\":\"How to use Number Methods in JavaScript?\",\"datePublished\":\"2021-08-05T11:38:40+00:00\",\"dateModified\":\"2022-04-13T16:30:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/\"},\"wordCount\":424,\"commentCount\":0,\"keywords\":[\"Javascript\",\"Methods in JavaScript\",\"toString( )\",\"Variable\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/\",\"name\":\"How to use Number Methods in JavaScript? - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2021-08-05T11:38:40+00:00\",\"dateModified\":\"2022-04-13T16:30:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-use-number-methods-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use Number Methods 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\\\/a40e0dd38feee7c2779460a804d49361\",\"name\":\"rajeshkumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"caption\":\"rajeshkumar\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/rajeshkumar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use Number Methods 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\/how-to-use-number-methods-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"How to use Number Methods in JavaScript? - scmGalaxy","og_description":"Number Methods toString ( ) toExponential ( ) toFixed ( ) toPrecision ( ) valueOf( ) isFinite( ) isInteger( ) [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/","og_site_name":"scmGalaxy","article_published_time":"2021-08-05T11:38:40+00:00","article_modified_time":"2022-04-13T16:30:46+00:00","author":"rajeshkumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rajeshkumar","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/"},"author":{"name":"rajeshkumar","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"headline":"How to use Number Methods in JavaScript?","datePublished":"2021-08-05T11:38:40+00:00","dateModified":"2022-04-13T16:30:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/"},"wordCount":424,"commentCount":0,"keywords":["Javascript","Methods in JavaScript","toString( )","Variable"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/","name":"How to use Number Methods in JavaScript? - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2021-08-05T11:38:40+00:00","dateModified":"2022-04-13T16:30:46+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-use-number-methods-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"How to use Number Methods 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\/a40e0dd38feee7c2779460a804d49361","name":"rajeshkumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","caption":"rajeshkumar"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/rajeshkumar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7442","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=7442"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7442\/revisions"}],"predecessor-version":[{"id":7447,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7442\/revisions\/7447"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=7442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=7442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=7442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}