{"id":713,"date":"2022-02-01T16:15:02","date_gmt":"2022-02-01T10:45:02","guid":{"rendered":"https:\/\/hostkicker.com\/news\/?p=713"},"modified":"2022-02-01T16:15:06","modified_gmt":"2022-02-01T10:45:06","slug":"useful-must-know-one-liners-in-javascript","status":"publish","type":"post","link":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/","title":{"rendered":"Useful Must Know One-Liners In JavaScript"},"content":{"rendered":"\n<p>Numerous developers across the globe make use of JavaScript, and the numbers are just increasing each day. What makes JavaScript famous as a programming language is its dynamic nature along with numerous unique features. Let us look at some one-liners in JavaScript that are absolutely useful and a must know.&nbsp;<\/p>\n\n\n\n<p><strong>1. Converting Fahrenheit to Celsius<\/strong>&nbsp;<\/p>\n\n\n\n<p>It is always good to be using a consistent unit of measurement of temperature, whether you choose to keep it as Fahrenheit or Celcius.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/t2Wsd-9XlojyyOX0B67EddOHD6yJwdGW7SPC5FZmbX8FsaP5XC8cLCfPXx0dB1DrcjY-m494mWJFuP-gOOKprqbL9KBdFhzx4xIJ3eoLyiLVASRXjFSLjMce7dlQwOAGUEXk5Msl\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>2. Random ID Generation<\/strong><\/p>\n\n\n\n<p>This can serve as an easy function to use for the time when you need prototyping and need to generate unique IDs.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/IUMiTxBIXNA12_THPADCXkOWFv9Fe5rfmNURYu-72ByxrWzQnkUKe4toIK7XTg0zPp1m7FNxOn6hPrBWgq-YIdpVFGApCyiiInDTUITDfbASywrY9Pv0YmCV-PvfoYZGPpccoUJ7\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>3. Generate a Random Number<\/strong>&nbsp;<\/p>\n\n\n\n<p>There are a lot of programs or scenarios where developers require the code to generate random numbers from within a given range. Math.random function is capable of achieving that and it can be transformed to get a range.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/n8ojyW97xDhieiBLXreld4PqNjgP53yh4l9Apd97Sjr5SUOUerIHxLOs-y6exyQf84ODRYtj1pDpI4n9fD1ThRBdhFsOFEdGpOJKFcvW5nDPXx-zCdu1xkS_Lgx0fFpwXGMRZ1v7\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>4. Shuffle An Array<\/strong><\/p>\n\n\n\n<p>There is not a module in JavaScript that can be used like the random.shuffle() function in Python. But there is still something that can be done to shuffle an array in JavaScript with the help of only one line of code.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/TIAyaDC9ngF1enm09ANZ07l2sdLtGN-slBQjonRFSmul7JFSCQqzefMg87QAMR-qyoainrom3Iue5xEKSG7tAU33VLManQIJo3gfkfyvo8S1lnF-Qa-fG83TbVcEjofttOcqwVSo\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>5. Getting a Random Boolean<\/strong><\/p>\n\n\n\n<p>The Math.random method of JavaScript is often used by developers when they need to generate random numbers from within a given range. For generating random Boolean numbers, to get either 1 or a 0, the checking method can be used, where it is checked whether it is below or above 0.5.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/zVQ4-1irK8sjXsHmSmWzOuO7kL10u5M4QCvqHt31ZipOPjRHbvWeMWdb39S3bUlvmSkcJ9P3qBTULtAjW1I-BMmVXKU21NSgzMYqLlyVPIg2BuyyDOnOSvT3BsV5ycLmcY18Bsoa\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>6. Generating a Random Hex Code<\/strong><\/p>\n\n\n\n<p>One-liners are often used as a challenge by developers. The one-liner shown below can be useful for generating a hexadecimal code at random. The code lime can generate up to 3 to 6 codes of colours that will help in creating a colour palette.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/PDaJMiGQAZF8YKNoOabt7OByqhMjByD_Gxt89vjZR6aGAbWOvXgqckUJZobJldzvGq92CCkOOXehJ4MVtvGW21DTQZvVG_A4JZscjWIy6p7d7casquIcjDmONDWkaUl1nqLMagUO\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>7. Reverse a String<\/strong><\/p>\n\n\n\n<p>Many methods in JavaScript can be used for reversing a string but to keep it simple and achieve it in one line, the below one-liner can be used.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/DH-LWNqnH2OOoskEE7FyVhHdbIouiQxWNMmZA--TUxiNKSE_9BZEo3gTU4YoexVroFlNNP7nyso02Y47ePQbjwPoxTaUjZhnsTr-wx-TAjt3i3MYaI_-lHVdapwIu1lr6464TrWj\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>8. Swapping Two Variables<\/strong><\/p>\n\n\n\n<p>The code here will show you how two variables in JavaScript can be swapped with a one-liner code, without the use of a third variable.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/socCNPFl_J9EObhM2HPBigIgKT_qofBfBPFOm2xf9NJf8oFtsw8PkcqC-4i9tFlH-pUXY1wvBMJC25CoP11J2OmkNmjtp6SAPEQc182f73BY6b8wIUs9XdBmtDy_eJzxwaU9K4as\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>9. Multiple Variable Assignment<\/strong><\/p>\n\n\n\n<p>Similar to Python, JavaScript also has the ability to assign values to more than one variable at the same time. This can be done with one line of code using a deconstructing technique.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/ZcjBJlJ1qv0PcAsib9t_WpXXlKGIQbI8eO7jGMRP_-gSOyR3rN07bmG2YcNqFZELrLw7zN7nlP9_Jl4XiTJI7FJmPnbN8EAllBbKq3iXyixtf60psTciZIwRBs_m6G7xBTK3kp43\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>10. Check If Even and Odd<\/strong><\/p>\n\n\n\n<p>A very basic code problem is determining whether a number is odd or even, a problem that every programmer faces in their journey. Many methods can be used for doing this, but a simple arrow function can be used to finish the task in just one line.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/zPCAxG7hUrvTUHMA0wzgSw1tWN7lyKeozZU3FfbpjAg6imEENkglFM9g3fDOuvZTXPH7aVe8J0w0xGhQO7X_CVlkT2cchhh8e_-yCXSeJgWmS4YxV-JK85ohMOd-QF2uM5piNxft\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>11. FizzBuzz<\/strong><\/p>\n\n\n\n<p>This is a famously asked question in interviews, checking the core of a developer or programmer. This problem needs the developer to write a code that will print numbers from 1 to 100. Fizz is printed if the number is a multiple of 3 and Buzz is printed if the number is a multiple of 5. This can be done in one line in JavaScript.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/XoKVWQm2ixTdtFm7bAfYNuE9mNO21ghYBXa3DX5ov13vY9lqIExqYO-vJeykzBfbrNcMWjErcVbkS8SLxJvX_F76w3WtJG0IRigWG0LxnfaXkIXRvgKpTtIwr9iIO-aJLju82eOg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>12. Palindrome<\/strong><\/p>\n\n\n\n<p>A string or a number that is the same when reversed is called a palindrome.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/FAIqtrQ-Bb1rkcDpVIgvh2ml90pKX3jVCcmx60q8lpx_whRkGfsdmAhMf19bO9I_PonkRCjN1DPilSy1ghVpxCmJLT1f3MFoIDB8omfq4R5DwGDrXGp8y-R_V-Tg-H1F-VFIOAQu\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>13. Checking Array Elements For A Condition<\/strong><\/p>\n\n\n\n<p>Many programmers encounter a situation in which they have to check the elements of an array, whether they meet a given condition or not. This can be completed with the following one-liner in JavaScript.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/YgTVqZfmY0mwpPRW62p8t_d9ZmfyFICNN0xfUJrkEEk0XzqIOIwrvFric3B0i12E9yLZbjSNp_b5rcULfWh3e6XE6BVztT7jUi_EQLcGJhnMuzvWrR2Xx4lWL_EmwLbyvzYVio4B\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>14. Calculating The Number Of Days<\/strong>&nbsp;<\/p>\n\n\n\n<p>Many problems require the counting of days between two given dates. The first is to find the absolute between those two dates and then divide that number with 86400000. This will share the output of time in milliseconds in one day, and then the result is rounded and returned.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/7Cma98jDnPhG3x7yZ1_sfTSrSGo9J9qXYnJf7cksTJIi-LlU2B3S86pqaOVUXV2-UomsZhvHesu22m7SG8AYWmIUGZuH8APLjK-ZGkXYfWW9cOQEvc210hpSyVery6yhrkWWADRG\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>15. Converting A String To A Number<\/strong><\/p>\n\n\n\n<p>A very simple method of converting a string to number is to make use of type conversion.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/sDXBwvg0zn8nyX_NF4_ZxutiKgZO8UXWbC_ApUzVXVw7pstkxgy2M7kcFEBr3dWwvZ1kKXAqOzVW8XFriPCGj04mHfiYn9BVXQ8WRfXIStandpJzHyjROqB_dAi8vrjmkdq51mdq\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>16. Merging Multiple Arrays<\/strong><\/p>\n\n\n\n<p>A merge of more than 2 arrays is required in a lot of problems and can be done easily as shown below.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/FimQXpeeQgNyJTxil2pfUeyRyE-tTX7mZMRWLUc_7RTw34tJPeo2ImXrVat77fcYNSBRZxY2LaMfeGWeCC5Ga9EJ6KThLZ8o0kyqkMrAieHi3ArDH_T8mgA_MuD5aYQfafaErLJe\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>17. Truncate a number<\/strong>&nbsp;<\/p>\n\n\n\n<p>To round a number to a fixed number of decimal places is necessary to achieve concise results. Math.pow() method is generally used for truncating the number to a required decimal point.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/0VMF6wP59W1q7gbi-VthvSkS1N2XmL9_fz1B4gAYMbMXWK7aaeMxDy5fnpN88KAJZolFWqqDok7e5qaAfuRs5uKcbFh07Ah-A006gMkiHwfEDsqTXUFIF27Lk5zvDNVKHmBuCDvf\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>18. Scrolling To Top Of Page<\/strong><\/p>\n\n\n\n<p>The common method window.scrollTo() can be used to scroll the control of the page to the top. You will have to provide the x and y coordinate to the function, to which coordinate you want the control to go. If you set both the coordinates at zero, automatically it will scroll to the top.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/mDfXzBX_4MbyVPSjwi-HVJoFJ0o8BYLuyOUPMV1UMtz426KEUeGmuP9q2bOagxldVQu7MzGaMmDZ9vgWjDDGG2rbmoRkSmQGpfg8h3DAD3vser3v-oCOCLZoUBNZAvkaXkUaSvzv\" alt=\"\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Numerous developers across the globe make use of JavaScript, and the numbers are just increasing each day. What makes JavaScript famous as a programming language is its dynamic nature along with numerous unique features. Let us look at some one-liners in JavaScript that are absolutely useful and a must know.&nbsp; 1. Converting Fahrenheit to Celsius&nbsp; [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":714,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Let us look at some one-liners in JavaScript that are absolutely useful and a must know<\/title>\n<meta name=\"description\" content=\"Let us look at some one-liners in JavaScript that are absolutely useful and a must know.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Useful Must Know One-Liners In JavaScript\" \/>\n<meta property=\"og:description\" content=\"Let us look at some one-liners in JavaScript that are absolutely useful and a must know.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Hostkicker\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-01T10:45:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-01T10:45:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png\" \/>\n\t<meta property=\"og:image:width\" content=\"693\" \/>\n\t<meta property=\"og:image:height\" content=\"511\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Olivia Smith\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Useful Must Know One-Liners In JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"Let us look at some one-liners in JavaScript that are absolutely useful and a must know.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olivia Smith\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/\"},\"author\":{\"name\":\"Olivia Smith\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#\\\/schema\\\/person\\\/f06306b595baa96c90a0491b941d7660\"},\"headline\":\"Useful Must Know One-Liners In JavaScript\",\"datePublished\":\"2022-02-01T10:45:02+00:00\",\"dateModified\":\"2022-02-01T10:45:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/\"},\"wordCount\":780,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/hostkicker.com\\\/news\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1\",\"articleSection\":[\"news\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/\",\"url\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/\",\"name\":\"Let us look at some one-liners in JavaScript that are absolutely useful and a must know\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/hostkicker.com\\\/news\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1\",\"datePublished\":\"2022-02-01T10:45:02+00:00\",\"dateModified\":\"2022-02-01T10:45:06+00:00\",\"description\":\"Let us look at some one-liners in JavaScript that are absolutely useful and a must know.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/hostkicker.com\\\/news\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/hostkicker.com\\\/news\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1\",\"width\":693,\"height\":511,\"caption\":\"Useful Must Know One-Liners In JavaScript\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/useful-must-know-one-liners-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Useful Must Know One-Liners In JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#website\",\"url\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/\",\"name\":\"Hostkicker\",\"description\":\"News\",\"publisher\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#organization\",\"name\":\"Hostkicker\",\"url\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/hostkicker.com\\\/news\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/hostkicker-logo-01.png?fit=940%2C218&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/hostkicker.com\\\/news\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/hostkicker-logo-01.png?fit=940%2C218&ssl=1\",\"width\":940,\"height\":218,\"caption\":\"Hostkicker\"},\"image\":{\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/#\\\/schema\\\/person\\\/f06306b595baa96c90a0491b941d7660\",\"name\":\"Olivia Smith\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/24a6b2466362238ad275f97a2f2fc49ce8d139c034114d6b9c52de1b12ebf1bd?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/24a6b2466362238ad275f97a2f2fc49ce8d139c034114d6b9c52de1b12ebf1bd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/24a6b2466362238ad275f97a2f2fc49ce8d139c034114d6b9c52de1b12ebf1bd?s=96&d=mm&r=g\",\"caption\":\"Olivia Smith\"},\"url\":\"https:\\\/\\\/hostkicker.com\\\/news\\\/author\\\/olivia\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Let us look at some one-liners in JavaScript that are absolutely useful and a must know","description":"Let us look at some one-liners in JavaScript that are absolutely useful and a must know.","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:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Useful Must Know One-Liners In JavaScript","og_description":"Let us look at some one-liners in JavaScript that are absolutely useful and a must know.","og_url":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/","og_site_name":"Hostkicker","article_published_time":"2022-02-01T10:45:02+00:00","article_modified_time":"2022-02-01T10:45:06+00:00","og_image":[{"width":693,"height":511,"url":"https:\/\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png","type":"image\/png"}],"author":"Olivia Smith","twitter_card":"summary_large_image","twitter_title":"Useful Must Know One-Liners In JavaScript","twitter_description":"Let us look at some one-liners in JavaScript that are absolutely useful and a must know.","twitter_image":"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1","twitter_misc":{"Written by":"Olivia Smith","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/#article","isPartOf":{"@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/"},"author":{"name":"Olivia Smith","@id":"https:\/\/hostkicker.com\/news\/#\/schema\/person\/f06306b595baa96c90a0491b941d7660"},"headline":"Useful Must Know One-Liners In JavaScript","datePublished":"2022-02-01T10:45:02+00:00","dateModified":"2022-02-01T10:45:06+00:00","mainEntityOfPage":{"@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/"},"wordCount":780,"commentCount":0,"publisher":{"@id":"https:\/\/hostkicker.com\/news\/#organization"},"image":{"@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1","articleSection":["news"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/","url":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/","name":"Let us look at some one-liners in JavaScript that are absolutely useful and a must know","isPartOf":{"@id":"https:\/\/hostkicker.com\/news\/#website"},"primaryImageOfPage":{"@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/#primaryimage"},"image":{"@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1","datePublished":"2022-02-01T10:45:02+00:00","dateModified":"2022-02-01T10:45:06+00:00","description":"Let us look at some one-liners in JavaScript that are absolutely useful and a must know.","breadcrumb":{"@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/#primaryimage","url":"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1","contentUrl":"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1","width":693,"height":511,"caption":"Useful Must Know One-Liners In JavaScript"},{"@type":"BreadcrumbList","@id":"https:\/\/hostkicker.com\/news\/useful-must-know-one-liners-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hostkicker.com\/news\/"},{"@type":"ListItem","position":2,"name":"Useful Must Know One-Liners In JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/hostkicker.com\/news\/#website","url":"https:\/\/hostkicker.com\/news\/","name":"Hostkicker","description":"News","publisher":{"@id":"https:\/\/hostkicker.com\/news\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hostkicker.com\/news\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hostkicker.com\/news\/#organization","name":"Hostkicker","url":"https:\/\/hostkicker.com\/news\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostkicker.com\/news\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/01\/hostkicker-logo-01.png?fit=940%2C218&ssl=1","contentUrl":"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/01\/hostkicker-logo-01.png?fit=940%2C218&ssl=1","width":940,"height":218,"caption":"Hostkicker"},"image":{"@id":"https:\/\/hostkicker.com\/news\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/hostkicker.com\/news\/#\/schema\/person\/f06306b595baa96c90a0491b941d7660","name":"Olivia Smith","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/24a6b2466362238ad275f97a2f2fc49ce8d139c034114d6b9c52de1b12ebf1bd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/24a6b2466362238ad275f97a2f2fc49ce8d139c034114d6b9c52de1b12ebf1bd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/24a6b2466362238ad275f97a2f2fc49ce8d139c034114d6b9c52de1b12ebf1bd?s=96&d=mm&r=g","caption":"Olivia Smith"},"url":"https:\/\/hostkicker.com\/news\/author\/olivia\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/hostkicker.com\/news\/wp-content\/uploads\/2022\/02\/Useful-Must-Know-One-Liners-In-JavaScript.png?fit=693%2C511&ssl=1","_links":{"self":[{"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/posts\/713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/comments?post=713"}],"version-history":[{"count":1,"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/posts\/713\/revisions"}],"predecessor-version":[{"id":715,"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/posts\/713\/revisions\/715"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/media\/714"}],"wp:attachment":[{"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/media?parent=713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/categories?post=713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostkicker.com\/news\/wp-json\/wp\/v2\/tags?post=713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}