{"id":8036,"date":"2025-12-12T10:22:11","date_gmt":"2025-12-12T15:22:11","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=8036"},"modified":"2025-12-12T10:22:12","modified_gmt":"2025-12-12T15:22:12","slug":"default-parameters-your-code-just-got-smarter","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/default-parameters-your-code-just-got-smarter\/","title":{"rendered":"Default parameters: your code just got smarter"},"content":{"rendered":"\n<p>Matt Smith with wonderfully straightforward writing on <a href=\"https:\/\/allthingssmitty.com\/2025\/06\/29\/default-parameters-your-code-just-got-smarter\/\">why default parameters for functions are a good idea<\/a>. I like the tip where you can still do it with an object-style param.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">createUser<\/span>(<span class=\"hljs-params\">{ name = <span class=\"hljs-string\">'Anonymous'<\/span>, age = <span class=\"hljs-number\">24<\/span> } = {}<\/span>) <\/span>{\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">`<span class=\"hljs-subst\">${name}<\/span> is <span class=\"hljs-subst\">${age}<\/span> years old.`<\/span>);\n}\n\ncreateUser(); <span class=\"hljs-comment\">\/\/ Anonymous is 24 years old.<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Matt Smith with wonderfully straightforward writing on why default parameters for functions are a good idea. I like the tip where you can still do it with an object-style param.<\/p>\n","protected":false},"author":1,"featured_media":8037,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[429,3],"class_list":["post-8036","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-beat","tag-default-parameters","tag-javascript"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/12\/pexels-photo-28380061.jpeg?fit=1880%2C1253&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/8036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=8036"}],"version-history":[{"count":1,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/8036\/revisions"}],"predecessor-version":[{"id":8038,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/8036\/revisions\/8038"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/8037"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=8036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=8036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=8036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}