{"id":324,"date":"2014-08-01T15:42:54","date_gmt":"2014-08-01T14:42:54","guid":{"rendered":"http:\/\/federicocoletto.com\/wp\/?p=324"},"modified":"2017-08-13T10:28:18","modified_gmt":"2017-08-13T09:28:18","slug":"equivalente-di-string-format-net-per-javascript","status":"publish","type":"post","link":"https:\/\/federicocoletto.com\/wp\/equivalente-di-string-format-net-per-javascript\/","title":{"rendered":"Equivalente di &#8220;String.Format&#8221; (.NET) per Javascript"},"content":{"rendered":"<div class=\"ContentItemShortDescription\" align=\"left\">\n<p>La funzione &#8220;System.String.Format&#8221; presente in dotNET \u00e8 tra le pi\u00f9 utili e fondamentali dell&#8217;ambiente. Sfortunatamente in Javascript non esiste nulla di simile. Il codice seguente consente di compensare questa lacuna.<\/p>\n<\/div>\n<h2>Codice<\/h2>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nif (!String.prototype.format) {\r\nString.prototype.format = function () {\r\nvar args = arguments;\r\nreturn this.replace(\/{(\\d+)}\/g, function (match, number) {\r\nreturn typeof args&#x5B;number] != 'undefined'\r\n? args&#x5B;number]\r\n: match\r\n;\r\n});\r\n};\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>La funzione &#8220;System.String.Format&#8221; presente in dotNET \u00e8 tra le pi\u00f9 utili e fondamentali dell&#8217;ambiente.<\/p>\n<p>Sfortunatamente in Javascript non esiste nulla di simile.<\/p>\n<p>Il codice seguente consente di compensare questa lacuna.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,5,7],"tags":[],"class_list":["post-324","post","type-post","status-publish","format-standard","hentry","category-javascript","category-programmazione","category-web"],"_links":{"self":[{"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/posts\/324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/comments?post=324"}],"version-history":[{"count":4,"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/posts\/324\/revisions"}],"predecessor-version":[{"id":793,"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/posts\/324\/revisions\/793"}],"wp:attachment":[{"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/media?parent=324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/categories?post=324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/federicocoletto.com\/wp\/wp-json\/wp\/v2\/tags?post=324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}