<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[ZGY]]></title><description><![CDATA[ Explore and share knowledge in programming, artificial intelligence, image generation technology, and expertise related to prompts.]]></description><link>https://zguyun.pan719.com/</link><image><url>https://zguyun.pan719.com/favicon.png</url><title>ZGY</title><link>https://zguyun.pan719.com/</link></image><generator>Ghost 5.75</generator><lastBuildDate>Wed, 28 Oct 2026 06:37:24 GMT</lastBuildDate><atom:link href="https://zguyun.pan719.com/blog/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[How does Postman request to download/export Excel/PDF files?]]></title><description><![CDATA[The steps for downloading or exporting Excel/PDF files in Postman are as follows: create a new interface, make a GET request, and click "Send and Download" or "Save response to file" in the response section to download.]]></description><link>https://zguyun.pan719.com/blog/how-does-postman-request-to-download-export-excel-pdf-files/</link><guid isPermaLink="false">65d56dabd393ab1547a6946a</guid><category><![CDATA[Postman]]></category><category><![CDATA[download/export Excel/PDF]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Mon, 21 Apr 2025 07:33:07 GMT</pubDate><content:encoded><![CDATA[<p>This article will provide a detailed explanation of how to request downloads and exports of Excel/PDF files in <a href="https://zguyun.pan719.com/blog/what-is-postman/">Postman</a>. Below are concise steps to help you easily accomplish this task. First, we will start with creating a new interface and guide you through the entire process step by step.</p><p></p><h2 id="steps-for-downloadingexporting-excelpdf-files-in-postman">Steps for downloading/exporting Excel/PDF files in Postman</h2><p></p><h2 id="1create-a-new-interface">1.Create a New Interface</h2><p>Create a new interface in Postman, file downloads are generally performed using GET requests. If you already have an interface prepared, you can skip this step.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-2d3dfa5b-a45c-4911-8239-8f2ce5bcf24e.png" class="kg-image" alt="Postman request to download/export Excel/PDF files" loading="lazy" width="2000" height="801" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-2d3dfa5b-a45c-4911-8239-8f2ce5bcf24e.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-2d3dfa5b-a45c-4911-8239-8f2ce5bcf24e.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-2d3dfa5b-a45c-4911-8239-8f2ce5bcf24e.png 1600w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-2d3dfa5b-a45c-4911-8239-8f2ce5bcf24e.png 2102w" sizes="(min-width: 720px) 720px"></figure><p></p><p>If you need to configure authentication-related fields, you can also do so in the request header under &quot;Headers&quot;:</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-5bcee3cd-9b3c-4612-81a1-d2cd4df2b47e.png" class="kg-image" alt="Postman request to download/export Excel/PDF files" loading="lazy" width="2000" height="963" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-5bcee3cd-9b3c-4612-81a1-d2cd4df2b47e.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-5bcee3cd-9b3c-4612-81a1-d2cd4df2b47e.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-5bcee3cd-9b3c-4612-81a1-d2cd4df2b47e.png 1600w, https://zguyun.pan719.com/content/images/size/w2400/2024/02/data-src-image-5bcee3cd-9b3c-4612-81a1-d2cd4df2b47e.png 2400w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="2send-request-and-download">2.Send Request and Download</h2><p>Once the interface is created, you can click the &quot;Send and Download&quot; button to send the request and download the file upon successful completion.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-b0c4d648-9d12-4a6b-8d36-46dd6e38991c.png" class="kg-image" alt="Postman request to download/export Excel/PDF files" loading="lazy" width="1898" height="904" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-b0c4d648-9d12-4a6b-8d36-46dd6e38991c.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-b0c4d648-9d12-4a6b-8d36-46dd6e38991c.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-b0c4d648-9d12-4a6b-8d36-46dd6e38991c.png 1600w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-b0c4d648-9d12-4a6b-8d36-46dd6e38991c.png 1898w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Alternatively, you can click the &quot;Save response to file&quot; button in the response section below to download the successfully requested file to your local system.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-c674a291-5b73-4348-8b31-9abc7e0f3ab1.png" class="kg-image" alt="Postman request to download/export Excel/PDF files" loading="lazy" width="2000" height="1184" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-c674a291-5b73-4348-8b31-9abc7e0f3ab1.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-c674a291-5b73-4348-8b31-9abc7e0f3ab1.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-c674a291-5b73-4348-8b31-9abc7e0f3ab1.png 1600w, https://zguyun.pan719.com/content/images/size/w2400/2024/02/data-src-image-c674a291-5b73-4348-8b31-9abc7e0f3ab1.png 2400w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="summary">Summary</h2><p>The steps for downloading or exporting Excel/PDF files in Postman are as follows: create a new interface, make a GET request, and click &quot;Send and Download&quot; or &quot;Save response to file&quot; in the response section to download.</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-does-postman-request-to-download-export-excel-pdf-files/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How does Postman request to download/export Excel/PDF files?</div><div class="kg-bookmark-description">The steps for downloading or exporting Excel/PDF files in Postman are as follows: create a new interface, make a GET request, and click &#x201C;Send and Download&#x201D; or &#x201C;Save response to file&#x201D; in the response section to download.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-2d3dfa5b-a45c-4911-8239-8f2ce5bcf24e.png" alt></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-enable-and-utilize-the-mock-server-in-postman/">How to enable and utilize the Mock server in Postman&#xFF1F;</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-use-predefined-variables-in-postman/">How to Use Predefined Variables in Postman?</a></li></ul>]]></content:encoded></item><item><title><![CDATA[What are Postman tests and how to write?]]></title><description><![CDATA[Postman's Tests are automatically executed scripts used to validate if request responses meet expectations. They are written in JavaScript and offer predefined assertion functions to check various aspects of responses.]]></description><link>https://zguyun.pan719.com/blog/what-are-postman-tests-and-how-to-write/</link><guid isPermaLink="false">65d80edad393ab1547a69577</guid><category><![CDATA[Postman]]></category><category><![CDATA[Postman Tests]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Mon, 21 Apr 2025 06:11:06 GMT</pubDate><content:encoded><![CDATA[<p>Tests in <a href="https://zguyun.pan719.com/blog/what-is-postman/">Postman</a> are scripts that are automatically executed after sending a request to verify if the response meets the expected criteria. These tests are written in JavaScript and come with a set of predefined assertion functions to check various aspects of the response, such as status codes, response body content, and response time.</p><p></p><p>Tests scripts can be written individually for each request or shared at the Collection or Folder level in Postman. The steps to write Tests in Postman are as follows:</p><p></p><h2 id="1create-a-new-request-in-postman">1.Create a new request in Postman</h2><p>Open Postman, create or open a request, then select the &quot;Tests&quot; tab in the top navigation bar of the request editor. In the &quot;Tests&quot; tab, you can write JavaScript code to validate the response.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-3cb23cf0-939d-4364-b3b6-1b758c2ee84e.png" class="kg-image" alt="Postman tests" loading="lazy" width="1280" height="623" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-3cb23cf0-939d-4364-b3b6-1b758c2ee84e.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-3cb23cf0-939d-4364-b3b6-1b758c2ee84e.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-3cb23cf0-939d-4364-b3b6-1b758c2ee84e.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="2write-the-script-in-tests">2.Write the script in Tests</h2><p>Predefined assertion functions can be used to check different aspects of the response, such as <code>pm.response.to.have.status()</code> to verify the status code, or <code>pm.response.to.have.jsonBody()</code> to check JSON response bodies. Below is a simple example demonstrating how to write a basic Tests script to validate the response status code:</p><pre><code class="language-javascript">// Check if the response status code is 200
pm.test(&quot;Status code is 200&quot;, function () {
    pm.response.to.have.status(200);
});</code></pre><p></p><h2 id="3send-the-request-and-verify-the-results">3.Send the request and verify the results</h2><p>After writing tests, click the &quot;Send&quot; button to send the request. Tests will be automatically executed, and the results will be displayed in the &quot;Test Results&quot; panel.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-d92148fb-a446-4735-9009-08454a416601.png" class="kg-image" alt="Postman tests" loading="lazy" width="1280" height="792" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-d92148fb-a446-4735-9009-08454a416601.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-d92148fb-a446-4735-9009-08454a416601.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-d92148fb-a446-4735-9009-08454a416601.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Apart from verifying status codes, there are many other common Tests scripts for validating various aspects of the request. Here are some examples:</p><p></p><ol><li>Check if specific fields are present in the response body:</li></ol><pre><code class="language-javascript">pm.test(&quot;Response body contains expected field&quot;, function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property(&apos;field_name&apos;);
});</code></pre><ol start="2"><li>Verify if the response time is within the expected range:</li></ol><pre><code class="language-javascript">pm.test(&quot;Response time is less than 500ms&quot;, function () {
    pm.expect(pm.response.responseTime).to.be.below(500);
});</code></pre><ol start="3"><li>Ensure that the response header contains specific information:</li></ol><pre><code class="language-javascript">pm.test(&quot;Response header contains expected value&quot;, function () {
    pm.response.to.have.header(&apos;header_name&apos;);
});</code></pre><ol start="4"><li>Check if specific fields in the response body have expected values:</li></ol><pre><code class="language-javascript">pm.test(&quot;Response body field has expected value&quot;, function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.field_name).to.eql(&apos;expected_value&apos;);
});</code></pre><ol start="5"><li>Validate if the response body conforms to a specific JSON structure:</li></ol><pre><code class="language-javascript">pm.test(&quot;Response body has expected JSON structure&quot;, function () {
    pm.response.to.have.jsonBody(&apos;json_schema&apos;);
});</code></pre><ol start="6"><li>Verify if the length of an array in the response body matches the expected length:</li></ol><pre><code class="language-javascript">pm.test(&quot;Response body array has expected length&quot;, function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.array_name).to.have.lengthOf(3);
});</code></pre><p></p><p>These are some common examples of Tests scripts. You can write custom Tests scripts according to your specific testing requirements. It is recommended to refer to the Postman official documentation for more information on predefined assertion functions and testing techniques.</p><p></p><h2 id="summary">Summary</h2><p><a href="https://zguyun.pan719.com/blog/what-is-postman/">Postman</a>&apos;s Tests are automatically executed scripts used to validate if request responses meet expectations. They are written in JavaScript and offer predefined assertion functions to check various aspects of responses. Tests can be written for each request or shared at the Collection/Folder level. Besides verifying status codes, Tests can check response bodies, response times, response headers, field values, etc.</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/what-are-postman-tests-and-how-to-write/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">What are Postman tests and how to write?</div><div class="kg-bookmark-description">Postman&#x2019;s Tests are automatically executed scripts used to validate if request responses meet expectations. They are written in JavaScript and offer predefined assertion functions to check various aspects of responses.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-3cb23cf0-939d-4364-b3b6-1b758c2ee84e.png" alt></div></a></figure><p></p><p>Reference&#xFF1A;</p><ul><li><a href="https://learning.postman.com/docs/introduction/overview/"><a href="https://learning.postman.com/docs/sending-requests/requests/"></a><a href="https://learning.postman.com/docs/sending-requests/response-data/response-data/"></a><a href="https://learning.postman.com/docs/writing-scripts/intro-to-scripts/">Postman Documentation</a></a></li></ul><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-extract-parameters-from-the-response-body-in-postman-tests/">How to extract parameters from the response body in Postman Tests?</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-extract-parameters-from-the-request-body-in-postman-tests/">How to extract parameters from the request body in Postman Tests?</a></li><li><a href="https://pan719.cc/">&#x5938;&#x514B;&#x4E91;&#x76D8;&#x8D44;&#x6E90;&#x5206;&#x4EAB;</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How does Postman send a DELETE request?]]></title><description><![CDATA[The steps for sending DELETE requests using Postman are as follows: first, create an interface in Postman and set the request method to DELETE; second, fill in the relevant URL, parameters, and headers; finally, click "Send" to send the request.]]></description><link>https://zguyun.pan719.com/blog/how-does-postman-send-a-delete-request/</link><guid isPermaLink="false">65d56a97d393ab1547a6944f</guid><category><![CDATA[Postman]]></category><category><![CDATA[DELETE]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Mon, 21 Apr 2025 05:25:07 GMT</pubDate><content:encoded><![CDATA[<p>This article will introduce the detailed steps for sending DELETE requests in <a href="https://zguyun.pan719.com/blog/what-is-postman/">Postman</a>. First, we need to create a new interface and set the request method to DELETE. After opening Postman, select DELETE from the dropdown menu of request methods, then fill in the relevant URL address, parameters, and request headers. Once everything is ready, click &quot;Send&quot; to send the request.</p><p></p><h2 id="steps-for-sending-a-delete-request-in-postman">Steps for sending a delete request in Postman</h2><p></p><h3 id="1create-a-new-interface-and-set-it-to-a-delete-request">1.Create a new interface and set it to a delete request</h3><p>Open Postman and create a new HTTP request interface.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-46f251b7-add8-4109-b4db-9f0dd01506b8.png" class="kg-image" alt="Postman send a DELETE request" loading="lazy" width="1280" height="763" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-46f251b7-add8-4109-b4db-9f0dd01506b8.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-46f251b7-add8-4109-b4db-9f0dd01506b8.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-46f251b7-add8-4109-b4db-9f0dd01506b8.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Then select DELETE from the dropdown menu of request methods. This dropdown menu is located to the left of the URL input box, and usually displays GET when first opened.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-0f1c9280-5a70-4e81-9823-181f0cdfd17c.png" class="kg-image" alt="Postman send a DELETE request" loading="lazy" width="1982" height="1035" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-0f1c9280-5a70-4e81-9823-181f0cdfd17c.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-0f1c9280-5a70-4e81-9823-181f0cdfd17c.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-0f1c9280-5a70-4e81-9823-181f0cdfd17c.png 1600w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-0f1c9280-5a70-4e81-9823-181f0cdfd17c.png 1982w" sizes="(min-width: 720px) 720px"></figure><p></p><h3 id="2fill-in-the-url-and-initiate-the-request">2.Fill in the URL and initiate the request</h3><p>After selecting the delete request in the previous step, fill in the relevant URL address and parameters (request headers, request body, etc.). If the API interface requires any headers, such as authentication tokens or other information, click on the Headers tab and enter the corresponding key-value pairs.</p><p></p><p>Paths are generally referenced using variables <code>{{}}</code>, but initially, you can also copy the entire path and paste it. After becoming familiar, you can then reference the values in the environment variables. After filling in the relevant information, click &quot;Send&quot; to send the request.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-5062cb31-461e-4810-9c7f-40502aad483d.png" class="kg-image" alt="Postman send a DELETE request" loading="lazy" width="2000" height="1184" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-5062cb31-461e-4810-9c7f-40502aad483d.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-5062cb31-461e-4810-9c7f-40502aad483d.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-5062cb31-461e-4810-9c7f-40502aad483d.png 1600w, https://zguyun.pan719.com/content/images/size/w2400/2024/02/data-src-image-5062cb31-461e-4810-9c7f-40502aad483d.png 2400w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="summary">Summary</h2><p>The steps for sending DELETE requests using Postman are as follows: first, create an interface in Postman and set the request method to DELETE; second, fill in the relevant URL, parameters, and headers; finally, click &quot;Send&quot; to send the request. It is worth noting that paths can use <code>{{}}</code> to reference variables.</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-does-postman-send-a-delete-request/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How does Postman send a DELETE request?</div><div class="kg-bookmark-description">The steps for sending DELETE requests using Postman are as follows: first, create an interface in Postman and set the request method to DELETE; second, fill in the relevant URL, parameters, and headers; finally, click &#x201C;Send&#x201D; to send the request.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-46f251b7-add8-4109-b4db-9f0dd01506b8.png" alt></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-does-postman-request-to-download-export-excel-pdf-files/">How does Postman request to download/export Excel/PDF files?</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-enable-and-utilize-the-mock-server-in-postman/">How to enable and utilize the Mock server in Postman&#xFF1F;</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How to clear cookies in Postman?]]></title><description><![CDATA[Clearing cookies in Postman can be accomplished through simple steps: first, clear all or specific cookies in the Cookie Manager, ensuring effectiveness after sending requests. ]]></description><link>https://zguyun.pan719.com/blog/how-to-clear-cookies-in-postman/</link><guid isPermaLink="false">65d6baf6d393ab1547a69503</guid><category><![CDATA[Postman]]></category><category><![CDATA[clear cookies]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Mon, 21 Apr 2025 04:27:07 GMT</pubDate><content:encoded><![CDATA[<p>Regardless of optimizing development processes or enhancing work efficiency, effectively managing cookies is an indispensable aspect. <a href="https://zguyun.pan719.com/blog/what-is-postman/">In Postman</a>, clearing cookies is an important step to ensure request accuracy and security. This article will provide a detailed guide on how to clear cookies in Postman. Below is a visual tutorial on how to perform this operation:</p><p></p><h2 id="1open-the-cookie-manager">1.Open the Cookie Manager</h2><p>Open a project in Postman, then select a request within the project. On the right side of the request tab, next to the &quot;Send&quot; button, you will see a button labeled &quot;Cookies.&quot; Click this &quot;Cookies&quot; button to open Postman&apos;s cookie manager.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-ae4191a3-02d7-4c7f-b951-e8d46126758f.png" class="kg-image" alt="clear cookies in Postman" loading="lazy" width="1280" height="659" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-ae4191a3-02d7-4c7f-b951-e8d46126758f.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-ae4191a3-02d7-4c7f-b951-e8d46126758f.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-ae4191a3-02d7-4c7f-b951-e8d46126758f.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="2clear-cookie-content">2.Clear Cookie Content</h2><p>Upon clicking, a window will appear listing all cookies associated with that request. To clear all cookies, you can click the &quot;Clear All Cookies&quot; button at the bottom of the window. If you only want to remove a specific cookie, locate it in the list and click the X icon next to it to delete.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-2da3a548-3bff-4100-86ab-077043bafceb.png" class="kg-image" alt="clear cookies in Postman" loading="lazy" width="1280" height="758" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-2da3a548-3bff-4100-86ab-077043bafceb.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-2da3a548-3bff-4100-86ab-077043bafceb.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-2da3a548-3bff-4100-86ab-077043bafceb.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Remember that for the deletion to take effect, you need to send the request afterward. This is one way to clear cookies in Postman.</p><p></p><p>Additionally, another method is to use the shortcut &quot;Ctrl+Shift+i&quot; to open Postman&apos;s built-in browser console. Here, you can also clear global cookies, similar to a browser&apos;s console.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-cc4bea82-97ae-4efe-97d9-ad54abcf8717.png" class="kg-image" alt="clear cookies in Postman" loading="lazy" width="1280" height="765" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-cc4bea82-97ae-4efe-97d9-ad54abcf8717.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-cc4bea82-97ae-4efe-97d9-ad54abcf8717.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-cc4bea82-97ae-4efe-97d9-ad54abcf8717.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Important Note: In some cases, it may be necessary to restart Postman to ensure that cleared cookies are not cached and used again. Also, ensure that you are following the instructions based on the actual interface of your Postman version, as software updates may change the design of the mentioned locations and icons.</p><p></p><h2 id="3confirm-cookie-clearance">3.Confirm Cookie Clearance</h2><p>After following the above steps, you can send a simple request to verify if the cookies have been cleared. If the previously cached cookies no longer affect the request, then the cookie clear was successful.</p><p></p><h2 id="conclusion">Conclusion</h2><p>Clearing cookies in <a href="https://zguyun.pan719.com/blog/what-is-postman/">Postman</a> can be accomplished through simple steps: first, clear all or specific cookies in the Cookie Manager, ensuring effectiveness after sending requests. Another method is to use the shortcut &quot;Ctrl+Shift+i&quot; to open the built-in browser console and clear global cookies. Restarting Postman can ensure that cleared cookies are not cached.</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-clear-cookies-in-postman/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to clear cookies in Postman?</div><div class="kg-bookmark-description">Clearing cookies in Postman can be accomplished through simple steps: first, clear all or specific cookies in the Cookie Manager, ensuring effectiveness after sending requests.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-ae4191a3-02d7-4c7f-b951-e8d46126758f.png" alt></div></a></figure><p></p><p>Reference&#xFF1A;</p><ul><li><a href="https://learning.postman.com/docs/introduction/overview/"><a href="https://learning.postman.com/docs/sending-requests/requests/"></a><a href="https://learning.postman.com/docs/sending-requests/response-data/response-data/"></a><a href="https://learning.postman.com/docs/writing-scripts/intro-to-scripts/"></a><a href="https://learning.postman.com/docs/sending-requests/response-data/cookies/">Postman Documentation</a></a></li></ul><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-add-a-cookie-in-postman/">How to add a Cookie in Postman?</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-convert-timestamps-in-postman/">How to convert timestamps in Postman?</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How to clear cache in Postman?]]></title><description><![CDATA[In Postman, the cache may contain old environment variables, global variables, or temporary session data, which can sometimes interfere with new request tests. To avoid potential issues, it's good practice to clear this cache. ]]></description><link>https://zguyun.pan719.com/blog/how-to-clear-cache-in-postman/</link><guid isPermaLink="false">65d6b6c8d393ab1547a694e7</guid><category><![CDATA[Postman]]></category><category><![CDATA[clear cache]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Mon, 21 Apr 2025 03:25:05 GMT</pubDate><content:encoded><![CDATA[<p>In Postman, the cache may contain old environment variables, global variables, or temporary session data, which can sometimes interfere with new request tests. To avoid potential issues, it&apos;s good practice to clear this cache. This article provides a step-by-step guide, including images, on how to clear the cache in Postman.</p><p></p><h2 id="precautions-before-clearing-postman-cache">Precautions before clearing Postman cache</h2><ul><li>Clearing the cache may delete some important data stored during testing. Please ensure whether backup is needed before clearing.</li><li>Clearing the cache will not delete saved requests and collections, so your data is safe.</li></ul><p></p><h2 id="how-to-clear-the-postman-cache">How to clear the Postman cache</h2><p></p><h3 id="1open-the-console">1.Open the Console</h3><p>Open the Postman application and at the bottom of the interface, click on the &quot;Console&quot; icon, then click on the right-pointing arrow icon (&#x2197;) to open the detailed console interface.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-9e714b10-5d22-4f7d-8c8c-7c27f212f845.png" class="kg-image" alt="clear cache in Postman" loading="lazy" width="2000" height="1184" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-9e714b10-5d22-4f7d-8c8c-7c27f212f845.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-9e714b10-5d22-4f7d-8c8c-7c27f212f845.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-9e714b10-5d22-4f7d-8c8c-7c27f212f845.png 1600w, https://zguyun.pan719.com/content/images/size/w2400/2024/02/data-src-image-9e714b10-5d22-4f7d-8c8c-7c27f212f845.png 2400w" sizes="(min-width: 720px) 720px"></figure><p></p><p>The detailed console interface of Postman is shown as in the image.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-66cdd120-5ce5-4af4-ab40-338ef73b4d73.png" class="kg-image" alt="clear cache in Postman" loading="lazy" width="2000" height="1184" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-66cdd120-5ce5-4af4-ab40-338ef73b4d73.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-66cdd120-5ce5-4af4-ab40-338ef73b4d73.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-66cdd120-5ce5-4af4-ab40-338ef73b4d73.png 1600w, https://zguyun.pan719.com/content/images/size/w2400/2024/02/data-src-image-66cdd120-5ce5-4af4-ab40-338ef73b4d73.png 2400w" sizes="(min-width: 720px) 720px"></figure><p></p><h3 id="2clear-the-postman-cache">2.Clear the Postman cache</h3><p></p><p><strong>Method One:</strong></p><p>In the Postman console interface, click on the &quot;Help -&gt; Clear Cache and Reload&quot; option. Postman will then clear the cache and restart.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-3c0556a0-a918-4777-b3d8-e191c87abd96.png" class="kg-image" alt="clear cache in Postman" loading="lazy" width="2000" height="1184" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-3c0556a0-a918-4777-b3d8-e191c87abd96.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-3c0556a0-a918-4777-b3d8-e191c87abd96.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-3c0556a0-a918-4777-b3d8-e191c87abd96.png 1600w, https://zguyun.pan719.com/content/images/size/w2400/2024/02/data-src-image-3c0556a0-a918-4777-b3d8-e191c87abd96.png 2400w" sizes="(min-width: 720px) 720px"></figure><p></p><p><strong>Method Two:</strong></p><p>Another way to clear the cache in Postman is by clicking on &quot;View -&gt; Developer -&gt; Show DevTools&quot; to open a console similar to a browser&apos;s, or by using the shortcut &quot;Ctrl+Shift+i&quot; to quickly open it.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-74af4e03-f272-4329-b040-12c452ab1f16.png" class="kg-image" alt="clear cache in Postman" loading="lazy" width="2000" height="1184" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-74af4e03-f272-4329-b040-12c452ab1f16.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-74af4e03-f272-4329-b040-12c452ab1f16.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-74af4e03-f272-4329-b040-12c452ab1f16.png 1600w, https://zguyun.pan719.com/content/images/size/w2400/2024/02/data-src-image-74af4e03-f272-4329-b040-12c452ab1f16.png 2400w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Once opened, click on &quot;Application&quot; to enter the management interface, where you can clear the relevant cache.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-0b5633ba-eca2-4ac5-8c78-05d6506ac533.png" class="kg-image" alt="clear cache in Postman" loading="lazy" width="2000" height="1184" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-0b5633ba-eca2-4ac5-8c78-05d6506ac533.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-0b5633ba-eca2-4ac5-8c78-05d6506ac533.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/02/data-src-image-0b5633ba-eca2-4ac5-8c78-05d6506ac533.png 1600w, https://zguyun.pan719.com/content/images/size/w2400/2024/02/data-src-image-0b5633ba-eca2-4ac5-8c78-05d6506ac533.png 2400w" sizes="(min-width: 720px) 720px"></figure><p></p><h3 id="3verify-postman-cache-clearance">3.Verify Postman cache clearance:</h3><p>After completing the above steps, create a simple request to verify whether the cache has been cleared. If the cached data no longer affects the request, then the cache clearance was successful.</p><p></p><h2 id="conclusion">Conclusion</h2><p>Postman is a powerful API testing tool, and managing its cache properly is crucial for ensuring the accuracy of tests. By following the steps outlined above, you can ensure that Postman&apos;s working environment is clean, thus safeguarding your API testing work.</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-clear-cache-in-postman/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to clear cache in Postman?</div><div class="kg-bookmark-description">In Postman, the cache may contain old environment variables, global variables, or temporary session data, which can sometimes interfere with new request tests. To avoid potential issues, it&#x2019;s good practice to clear this cache.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-9e714b10-5d22-4f7d-8c8c-7c27f212f845.png" alt></div></a></figure><p></p><p>Reference&#xFF1A;</p><ul><li><a href="https://learning.postman.com/docs/introduction/overview/"><a href="https://learning.postman.com/docs/sending-requests/requests/"></a><a href="https://learning.postman.com/docs/sending-requests/response-data/response-data/"></a><a href="https://learning.postman.com/docs/writing-scripts/intro-to-scripts/"></a><a href="https://learning.postman.com/docs/sending-requests/response-data/cookies/">Postman Documentation</a></a></li></ul><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-clear-cookies-in-postman/">How to clear cookies in Postman?</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-add-a-cookie-in-postman/">How to add a Cookie in Postman?</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How to download older versions in Postman?]]></title><description><![CDATA[In certain scenarios, there may be a need to install and utilize older versions of Postman. This article will outline the steps to uninstall the local Postman application, view historical versions, and download the desired version.]]></description><link>https://zguyun.pan719.com/blog/how-to-download-history-versions-in-postman/</link><guid isPermaLink="false">65d6b2b7d393ab1547a694ca</guid><category><![CDATA[Postman]]></category><category><![CDATA[download history versions]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Mon, 21 Apr 2025 02:06:05 GMT</pubDate><content:encoded><![CDATA[<p>In certain scenarios, there may be a need to install and utilize older versions of <a href="https://zguyun.pan719.com/blog/what-is-postman/">Postman</a>. This article will outline the steps to uninstall the local Postman application, view historical versions, and download the desired version.</p><p></p><h2 id="1uninstalling-the-local-postman">1.Uninstalling the Local Postman</h2><p>When installing an older version of Postman, it&apos;s essential to remove the existing local Postman to avoid unexpected conflicts. If you&apos;re using Windows, you can uninstall the current version of Postman from the control panel.</p><p></p><h2 id="2viewing-postmans-historical-versions">2.Viewing Postman&apos;s Historical Versions</h2><p>To install historical versions of Postman, you can visit their official website to review the descriptions and functionalities of each version. Then, you can select the version you wish to download.</p><p></p><p>Link: <a href="https://www.postman.com/release-notes/postman-app/">Postman Release Notes</a></p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-dfd9522c-c4af-4cc1-9949-a8728b35433c.png" class="kg-image" alt="download history versions in Postman" loading="lazy" width="1280" height="677" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-dfd9522c-c4af-4cc1-9949-a8728b35433c.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-dfd9522c-c4af-4cc1-9949-a8728b35433c.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-dfd9522c-c4af-4cc1-9949-a8728b35433c.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="3downloading-postmans-historical-versions">3.Downloading Postman&apos;s Historical Versions</h2><p>Once you&apos;ve decided on the version you want to download, you can click the links below to download the corresponding historical versions. Currently, historical versions are available only for macOS and Windows systems, as shown below:</p><p></p><p>For macOS: <a href="https://mac.filehorse.com/download-postman/old-versions/">Postman Old Versions</a></p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-6b0a8231-0c31-441f-ad4b-d9a8f5d2da69.png" class="kg-image" alt="download history versions in Postman" loading="lazy" width="1280" height="665" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-6b0a8231-0c31-441f-ad4b-d9a8f5d2da69.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-6b0a8231-0c31-441f-ad4b-d9a8f5d2da69.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-6b0a8231-0c31-441f-ad4b-d9a8f5d2da69.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>For Windows: <a href="https://www.filehorse.com/download-postman/old-versions/">Postman Old Versions</a></p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-db8d1500-047f-4d5f-8c96-bfaced8e83cb.png" class="kg-image" alt="download history versions in Postman" loading="lazy" width="1280" height="662" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/02/data-src-image-db8d1500-047f-4d5f-8c96-bfaced8e83cb.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/02/data-src-image-db8d1500-047f-4d5f-8c96-bfaced8e83cb.png 1000w, https://zguyun.pan719.com/content/images/2024/02/data-src-image-db8d1500-047f-4d5f-8c96-bfaced8e83cb.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Choose a version and click &quot;Download&quot; to proceed.</p><p></p><h2 id="conclusion">Conclusion</h2><p>In this guide, we&apos;ve covered the steps to uninstall the local Postman, view historical versions, and download specific versions to avoid conflicts.</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-download-history-versions-in-postman/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to download history versions in Postman?</div><div class="kg-bookmark-description">In certain scenarios, there may be a need to install and utilize older versions of Postman. This article will outline the steps to uninstall the local Postman application, view historical versions, and download the desired version.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/02/data-src-image-dfd9522c-c4af-4cc1-9949-a8728b35433c.png" alt></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-clear-cache-in-postman/">How to clear cache in Postman?</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-clear-cookies-in-postman/">How to clear cookies in Postman?</a></li></ul>]]></content:encoded></item><item><title><![CDATA[4 Best AI Video Generation Tools]]></title><description><![CDATA[A series of remarkable AI video tools such as Stable Video, Sora, Pika, and Runway Gen-2 are changing the way video content creation is done with their powerful features and flexible applications. ]]></description><link>https://zguyun.pan719.com/blog/best-ai-video-generation-tools/</link><guid isPermaLink="false">65e34c93d393ab1547a6985c</guid><category><![CDATA[AI]]></category><category><![CDATA[Video Generation Tools]]></category><category><![CDATA[Stable Video]]></category><category><![CDATA[Sora]]></category><category><![CDATA[Pika]]></category><category><![CDATA[Runway]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Mon, 21 Apr 2025 01:12:05 GMT</pubDate><content:encoded><![CDATA[<p>In recent years, with the rapid development of artificial intelligence technology, the field of video generation has witnessed a new wave of innovation. A series of remarkable <a href="https://ai.promptchoose.com/">AI</a> video tools such as Stable Video, Sora, Pika, and Runway Gen-2 are changing the way video content creation is done with their powerful features and flexible applications. Let&apos;s delve into these tools to understand how they are driving the transformation in the field of video creation.</p><p></p><h2 id="1stable-video">1.Stable Video</h2><p></p><h3 id="11-what-is-stable-video">1.1 What is &quot;Stable Video&quot;?</h3><p>&quot;Stable Video&quot; is a video generation tool based on artificial intelligence technology. It can automatically generate exquisite video content based on the text or images you provide. Without any professional video production experience, you can easily create high-quality videos.</p><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-d403cb86-6389-416a-ae48-03c86693c406.png" class="kg-image" alt="Stable Video Video Generation Tools" loading="lazy" width="1885" height="879" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-d403cb86-6389-416a-ae48-03c86693c406.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-d403cb86-6389-416a-ae48-03c86693c406.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/03/data-src-image-d403cb86-6389-416a-ae48-03c86693c406.png 1600w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-d403cb86-6389-416a-ae48-03c86693c406.png 1885w" sizes="(min-width: 720px) 720px"></figure><p></p><h3 id="12-what-are-the-features-of-stable-video">1.2 What are the features of &quot;Stable Video&quot;?</h3><ol><li>Text-to-Video: Convert your text content into dynamic video scenes, making it easier for your audience to understand and remember your information.</li><li>Image-to-Video: Convert your images into dynamic video effects, increasing visual impact and attractiveness.</li><li>Multiple style choices: Choose different styles and templates according to your needs and brand image to customize unique video content.</li><li>Video editing tools: Edit, add subtitles, adjust audio, etc., on the generated video to make your video more perfect.</li></ol><p></p><h3 id="13-use-cases">1.3 Use cases</h3><ol><li>Content marketing: Showcase your products or services to potential customers through video to increase brand awareness and sales conversion rates.</li><li>Social media: Create interesting and engaging video content to attract more attention and shares, expanding your social media influence.</li><li>Education and training: Produce instructional videos and training videos to provide a more intuitive and vivid learning experience, improving learning effectiveness and engagement.</li></ol><p></p><h3 id="14-official-website">1.4 <strong>Official website</strong></h3><p></p><p>https://www.stablevideo.com/</p><p></p><h3 id="15-pricing">1.5 Pricing</h3><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/image-1.png" class="kg-image" alt="Stable Video Pricing - Video Generation Tools" loading="lazy" width="1340" height="652" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/image-1.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/image-1.png 1000w, https://zguyun.pan719.com/content/images/2024/03/image-1.png 1340w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="2sora">2.Sora</h2><p></p><h3 id="21-sora-text-to-video-overview">2.1 Sora Text-to-Video Overview</h3><p>Sora is a model developed by OpenAI for text-to-video conversion. By teaching AI to understand and simulate motion in the physical world, it aims to train models that can help people solve problems requiring real-world interaction. Sora can generate videos up to one minute in length while maintaining visual quality and adherence to user prompts.</p><figure class="kg-card kg-embed-card"><div><blockquote class="twitter-tweet"><p lang="en" dir="ltr"><a href="https://twitter.com/hashtag/SoraAI?src=hash&amp;ref_src=twsrc%5Etfw">#SoraAI</a> A new Sora video about a huge translucent jellyfish.<br>Prompt:<br>&#x201C;A surreal scene unfolds as a giant, translucent jellyfish floats gracefully through a deserted cityscape at dusk. The scene is shot on 35mm film.&#x201D;<br>Video generated by Sora<br>from <a href="https://twitter.com/Sora_Token?ref_src=twsrc%5Etfw">@Sora_Token</a> <a href="https://twitter.com/hashtag/Sora?src=hash&amp;ref_src=twsrc%5Etfw">#Sora</a> <a href="https://twitter.com/hashtag/SoraAI?src=hash&amp;ref_src=twsrc%5Etfw">#SoraAI</a> <a href="https://twitter.com/hashtag/OpenAI?src=hash&amp;ref_src=twsrc%5Etfw">#OpenAI</a>&#x2026; <a href="https://t.co/nUSQYWhgtm">pic.twitter.com/nUSQYWhgtm</a></p>&#x2014; Sora (@Sora_Token) <a href="https://twitter.com/Sora_Token/status/1763095643122495518?ref_src=twsrc%5Etfw">February 29, 2024</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div></figure><h3 id="22-sora-product-features">2.2 Sora Product Features</h3><ol><li>Generating Complex Scenes: Sora is capable of generating complex scenes with multiple characters, specific types of motion, and accurate details of themes and backgrounds.</li><li>Language Understanding: The model deeply understands language, accurately interpreting prompts and generating attention-grabbing characters that express vivid emotions.</li><li>Creating Multiple Shots: Sora can create multiple shots within a single generated video, accurately preserving characters and visual styles.</li></ol><p></p><h3 id="23-use-cases">2.3 Use cases</h3><ol><li>Security Assessment: Red team members can use Sora to assess critical areas that may pose threats or risks.</li><li>Feedback from Creative Professionals: Providing access to visual artists, designers, and filmmakers to gather feedback on how to advance the model&apos;s usefulness for creative professionals.</li></ol><p></p><h3 id="24-official-website">2.4 Official Website</h3><p></p><p>https://openai.com/sora</p><p></p><h3 id="25-pricing">2.5 Pricing</h3><p>Coming soon.</p><p></p><h2 id="3pika">3.Pika</h2><p></p><h3 id="31-what-is-pika%EF%BC%9F">3.1 What is Pika&#xFF1F;</h3><p>Pika is an AI video generation and editing tool recently launched by the popular artificial intelligence startup Pika Labs. This tool can transform any idea into a video, allowing users to quickly generate videos in styles such as 3D animation, anime, cartoons, and movies by simply inputting text or images.</p><figure class="kg-card kg-embed-card"><div><blockquote class="twitter-tweet"><p lang="en" dir="ltr">Introducing Pika 1.0, the idea-to-video platform that brings your creativity to life.<br><br>Create and edit your videos with AI.<br><br>Rolling out to new users on web and discord, starting today. Sign up at <a href="https://t.co/JHRrinsIwx">https://t.co/JHRrinsIwx</a> <a href="https://t.co/Rve3I2FzmK">pic.twitter.com/Rve3I2FzmK</a></p>&#x2014; Pika (@pika_labs) <a href="https://twitter.com/pika_labs/status/1729510078959497562?ref_src=twsrc%5Etfw">November 28, 2023</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div></figure><h3 id="32-product-features">3.2 Product Features</h3><ul><li>Text/Image to Video: Utilize AI to create short, high-quality videos with just a few lines of text input or by uploading images.</li><li>Video to Video: Transform existing videos into different styles, including different characters and objects, while maintaining the structure of the original video.</li><li>Video Aspect Ratio Expansion: Expand the canvas or aspect ratio of videos, such as converting from 9:16 vertical to 16:9 horizontal intelligently. The AI model will predict content beyond the original video boundaries.</li><li>Video Content Alteration: AI edits the content or objects in video frames, such as changing someone&apos;s clothes, adding another character, changing the environment, or adding props.</li></ul><p></p><h3 id="33-official-website">3.3 Official Website</h3><p></p><p>https://pika.art/</p><p></p><h3 id="34-pricing">3.4 Pricing</h3><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-f6ee4879-00f0-48d1-9785-6ce130a954e0.png" class="kg-image" alt="Pika Pricing - Video Generation Tools" loading="lazy" width="1883" height="879" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-f6ee4879-00f0-48d1-9785-6ce130a954e0.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-f6ee4879-00f0-48d1-9785-6ce130a954e0.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/03/data-src-image-f6ee4879-00f0-48d1-9785-6ce130a954e0.png 1600w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-f6ee4879-00f0-48d1-9785-6ce130a954e0.png 1883w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="4runway">4.Runway</h2><p></p><h3 id="41-what-is-runway-gen-2">4.1 What is &apos;Runway Gen-2&apos;?</h3><p>Gen-2 is a multimodal AI system developed by Runway that can generate new videos using text, images, or video clips. It applies the composition and style of images or text prompts to the structure of the source video, achieving realistic and consistent new video synthesis (Video to Video). Alternatively, it can generate entirely new videos using only text prompts (Text to Video). It&apos;s like shooting new content without actually shooting anything.</p><figure class="kg-card kg-embed-card"><div><blockquote class="twitter-tweet"><p lang="en" dir="ltr">Creative Dialogues Episode 3 coming soon.<br><br>With Golan Levin (<a href="https://twitter.com/golan?ref_src=twsrc%5Etfw">@golan</a>) and Claire Hentschker (<a href="https://twitter.com/ntschk?ref_src=twsrc%5Etfw">@ntschk</a>).<a href="https://t.co/Ok5qy9In4W">https://t.co/Ok5qy9In4W</a> <a href="https://t.co/zNd8x5rlgx">pic.twitter.com/zNd8x5rlgx</a></p>&#x2014; Runway (@runwayml) <a href="https://twitter.com/runwayml/status/1763565387323458040?ref_src=twsrc%5Etfw">March 1, 2024</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div></figure><p></p><h3 id="42-what-features-does-runway-gen-2-have">4.2 What features does &apos;Runway Gen-2&apos; have?</h3><p>1. Text to Video: Synthesize videos in any style imaginable using only text prompts.</p><p>2. Text + Image to Video: Generate videos using driven images and text prompts.</p><p>3. Image to Video: Generate videos using only driven images (Variations Mode).</p><p>4. Stylization: Apply the style of any image or prompt to each frame of the video.</p><p>5. Storyboard: Transform the model into fully stylized and animated renders.</p><p>6. Mask: Isolate and modify subjects in videos with simple text prompts.</p><p>7. Render: Transform untextured renders into realistic outputs by applying input images or prompts.</p><p>8. Customization: Unlock the full potential of Gen-2 by customizing the model for higher fidelity results.</p><p></p><h3 id="43-use-cases">4.3 Use cases</h3><p>1. Filmmaking: Gen-2 can transform any image, video clip, or text prompt into captivating movie segments, bringing new magic to filmmaking.</p><p>2. Video Creation: Whether driven by text prompts or image prompts, Gen-2 assists users in creating videos in various styles.</p><p>3. Rendering and Animation: Gen-2 can convert untextured renders into realistic outputs and transform the model into fully stylized and animated renders.</p><p></p><h3 id="44-official-website">4.4 Official Website</h3><p>https://research.runwayml.com/gen2</p><p></p><h3 id="45-pricing">4.5 Pricing</h3><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-935f86f8-1448-43a3-98d7-a2ef64d9e7b9.png" class="kg-image" alt="Runway Pricing - Video Generation Tools" loading="lazy" width="1890" height="879" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-935f86f8-1448-43a3-98d7-a2ef64d9e7b9.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-935f86f8-1448-43a3-98d7-a2ef64d9e7b9.png 1000w, https://zguyun.pan719.com/content/images/size/w1600/2024/03/data-src-image-935f86f8-1448-43a3-98d7-a2ef64d9e7b9.png 1600w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-935f86f8-1448-43a3-98d7-a2ef64d9e7b9.png 1890w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="summary">Summary</h2><p>In the realm of AI-powered video generation tools, Stable Video, Sora, Pika, and Runway Gen-2 stand out as versatile and innovative solutions.</p><p></p><p>Stable Video offers seamless conversion of text and images into dynamic videos, catering to diverse needs in content marketing, social media, and education.</p><p></p><p>Sora, developed by OpenAI, boasts the capability of generating complex video scenes with deep language understanding, making it invaluable for security assessment and creative endeavors.</p><p></p><p>Pika, from Pika Labs, empowers users to effortlessly create videos in various styles, including 3D animation and cartoons, through simple text or image inputs.</p><p></p><p>Runway Gen-2, a multimodal AI system, revolutionizes video creation with its ability to generate new videos from text, images, or clips, enabling filmmakers, creators, and designers to unlock new possibilities in storytelling and visual expression.</p><p></p><p>Each tool offers unique features and applications, catering to different user needs and preferences in the ever-evolving landscape of video content creation.</p><p></p><p><strong>Official Websites:</strong></p><ul><li>Stable Video: https://www.stablevideo.com/</li><li>Sora: https://openai.com/sora</li><li>Pika: https://pika.art/</li><li>Runway Gen-2: https://research.runwayml.com/gen2</li></ul><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/best-ai-video-generation-tools/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">4 Best AI Video Generation Tools</div><div class="kg-bookmark-description">A series of remarkable AI video tools such as Stable Video, Sora, Pika, and Runway Gen-2 are changing the way video content creation is done with their powerful features and flexible applications.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-d403cb86-6389-416a-ae48-03c86693c406.png" alt></div></a></figure><p></p><p><strong>Learn more:</strong></p><ul><li><a href="https://zguyun.pan719.com/blog/best-ai-text-to-speech-tools/">5 Best AI Text to Speech Tools</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How to Disable Back Button in Browser Using JavaScript？]]></title><description><![CDATA[This article introduces two methods: one is using the browser's History API, and the other is the popstate event of the Window object.]]></description><link>https://zguyun.pan719.com/blog/how-to-disable-back-button-in-browser-using-javascript/</link><guid isPermaLink="false">65ef29a0d393ab1547a69a59</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Disable Back Button]]></category><category><![CDATA[download history versions]]></category><category><![CDATA[popstate]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Mon, 21 Apr 2025 00:16:05 GMT</pubDate><content:encoded><![CDATA[<p>In this article, we&apos;re going to discuss how to disable the back button in a browser using <a href="https://zguyun.pan719.com/blog/how-to-run-a-javascript-file-in-visual-studio-code/">JavaScript</a>. You may have encountered a situation where, while developing a web application, you don&apos;t want users to navigate back to the previous page using the browser&apos;s back button, as it could lead to data loss or other unexpected scenarios. So, what can you do? Don&apos;t worry, this article will show you several methods to achieve this goal.</p><p></p><h2 id="understanding-the-back-button">Understanding the Back Button</h2><p>Firstly, we need to understand how the browser&apos;s back button works. When you click the back button on a webpage, you&apos;re actually navigating backward in the browser&apos;s history, returning to previously visited pages.</p><p></p><h2 id="requirement-analysis">Requirement Analysis</h2><p>Why do we need to disable the browser&apos;s back button? Imagine you&apos;re filling out a lengthy form or editing a long article, and accidentally click the back button, losing all your input! In such cases, disabling the back button becomes essential.</p><p></p><h2 id="technical-background">Technical Background</h2><p>So, how do we disable the back button in JavaScript? Here, we need to grasp some key concepts, such as browser history and how to manage and manipulate this history using JavaScript.</p><p></p><h3 id="1browser-history">1.Browser History</h3><p>The browser&apos;s history is a list that records the web pages a user has visited in the browser. Each time a user visits a new webpage, its URL is added to the browser&apos;s history. By using the browser&apos;s forward and back buttons, users can navigate between visited webpages.</p><p></p><h3 id="2history-management-in-javascript">2.History Management in JavaScript</h3><p>JavaScript provides APIs to manage the browser&apos;s history. The most commonly used is the History object, which offers a set of methods allowing us to access and manipulate the browser&apos;s history:</p><ul><li><code>history.back()</code>: This method lets the browser navigate back to the previous page in its history.</li><li><code>history.forward()</code>: This method lets the browser navigate forward to the next page in its history.</li><li><code>history.go()</code>: This method lets the browser navigate to a specified page in its history.</li></ul><p>Using these methods, we can simulate user clicks on the browser&apos;s forward and back buttons in JavaScript, thereby controlling the browser&apos;s history.</p><p></p><h3 id="3browser-events">3.Browser Events</h3><p>Additionally, JavaScript provides events for interacting with the browser. One such event is the <code>popstate</code> event, which is triggered when the browser&apos;s history changes (e.g., when the user clicks the forward or back buttons). By listening to the <code>popstate</code> event, we can capture user navigation actions and take appropriate measures, such as disabling the back button if necessary.</p><p></p><p>Understanding these concepts allows us to better utilize JavaScript to control browser behavior, including functionalities like disabling the back button.</p><p></p><h2 id="methods-to-disable-the-back-button-in-the-browser">Methods to Disable the Back Button in the Browser</h2><p></p><h3 id="1using-the-history-api">1.Using the History API</h3><p>The History API allows manipulation of the browser&apos;s history, enabling the disabling of the back button. We can simulate disabling the back button by replacing the current history. Here&apos;s a simple example code:</p><pre><code class="language-javascript">// Disable the back button
function disableBackButton() {
    history.pushState(null, null, location.href);
    window.onpopstate = function () {
        history.go(1);
    };
}

// Call the disable back button function
disableBackButton();</code></pre><p>In this example, we define a function named <code>disableBackButton</code>. It utilizes the <code>history.pushState()</code> method to replace the current history, making it so that there&apos;s no history for the back button to backtrack to. Then, by listening to the <code>window.onpopstate</code> event and calling <code>history.go(1)</code> when the event is triggered, we ensure that when the user clicks the back button, the browser navigates forward again instead of returning to the previous page.</p><p></p><h3 id="2using-the-popstate-event-of-the-window-object">2.Using the <code>popstate</code> Event of the Window Object</h3><p>Another method is to utilize the <code>popstate</code> event, which is triggered when the browser&apos;s history changes. We can listen to this event and prevent the default behavior to disable the back button. Here&apos;s example code:</p><pre><code class="language-javascript">// Disable the back button
function disableBackButton() {
    window.addEventListener(&apos;popstate&apos;, function (event) {
        history.pushState(null, null, location.href);
    });
}

// Call the disable back button function
disableBackButton();</code></pre><p>In this example, we define a function named <code>disableBackButton</code>. It listens to the <code>popstate</code> event and calls <code>history.pushState()</code> to replace the current history when the event is triggered, effectively disabling the back button.</p><p></p><h3 id="3method-comparison">3.Method Comparison</h3><p>So, what are the differences between these two methods? Using the History API method is more flexible because it allows direct manipulation of the browser&apos;s history and precise control over its state. However, it may require more code to implement. On the other hand, using the <code>popstate</code> event method is relatively simple but may not be as flexible since we can only listen to history changes and cannot directly manipulate the history. Therefore, when choosing a method, it&apos;s essential to decide based on specific requirements.</p><p></p><h2 id="summary">Summary</h2><p>In conclusion, it&apos;s feasible to disable the browser&apos;s back button using <a href="https://zguyun.pan719.com/blog/how-to-run-a-javascript-file-in-visual-studio-code/">JavaScript</a>, and it can be very useful in certain situations. Whether using the History API or the <code>popstate</code> event, both methods can help us achieve this goal. However, remember to consider various limitations and potential issues when applying these methods!</p><p></p><p><strong>Reference Links:</strong></p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/History_API"><u>MDN Web Docs: History API</u></a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event"><u>MDN Web Docs: popstate event</u></a></li></ul><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-disable-back-button-in-browser-using-javascript/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to Disable Back Button in Browser Using JavaScript&#xFF1F;</div><div class="kg-bookmark-description">This article introduces two methods: one is using the browser&#x2019;s History API, and the other is the popstate event of the Window object.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-disable-selection-options-using-javascript/">How to disable selection options using JavaScript?</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-convert-html-to-plain-text-using-javascript/">How to convert HTML to plain text using JavaScript?</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How to format dates in JavaScript?]]></title><description><![CDATA[This article discusses how to format dates in JavaScript, using both native built-in JavaScript methods and third-party libraries such as moment.js.]]></description><link>https://zguyun.pan719.com/blog/how-to-format-dates-in-javascript/</link><guid isPermaLink="false">65f70c68d393ab1547a69be7</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[format dates]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Sun, 20 Apr 2025 23:45:23 GMT</pubDate><content:encoded><![CDATA[<p>When writing <a href="https://zguyun.pan719.com/blog/how-to-copy-an-array-in-javascript/">JavaScript</a> applications, date formatting is a common task. Today, we will explore how to format dates in JavaScript, and I will demonstrate these methods through code examples.</p><p></p><h2 id="introduction-to-date-objects-in-javascript"><strong>Introduction to Date Objects in JavaScript</strong></h2><p>The date object in JavaScript is <code>Date </code>, which allows us to get and set the date and time. Here are some common methods:</p><pre><code class="language-javascript">// Create a Date object
let now = new Date();

// Get year, month, and date
let year = now.getFullYear();
let month = now.getMonth() + 1; // Note: months start from 0
let date = now.getDate();

// Get hours, minutes, and seconds
let hours = now.getHours();
let minutes = now.getMinutes();
let seconds = now.getSeconds();</code></pre><p></p><h2 id="the-need-for-date-formatting"><strong>The need for date formatting</strong></h2><p>Date formatting is necessary in various contexts, such as displaying dates on web pages, logging, data processing, etc. We need to format dates flexibly according to different needs.</p><p></p><h2 id="basic-date-formatting-methods"><strong>Basic date formatting methods</strong></h2><p>Basic date formatting can be achieved through string concatenation or using built-in methods as follows:</p><pre><code class="language-javascript">// Get current date and time
let now = new Date();

// Get year, month, date, hours, minutes, seconds
let year = now.getFullYear();
let month = now.getMonth() + 1;
let date = now.getDate();
let hours = now.getHours();
let minutes = now.getMinutes();
let seconds = now.getSeconds();

// Format as yyyy-mm-dd
let formattedDate = `${year}-${month &lt; 10 ? &apos;0&apos; + month : month}-${date &lt; 10 ? &apos;0&apos; + date : date}`;

// Format as hh:mm:ss
let formattedTime = `${hours &lt; 10 ? &apos;0&apos; + hours : hours}:${minutes &lt; 10 ? &apos;0&apos; + minutes : minutes}:${seconds &lt; 10 ? &apos;0&apos; + seconds : seconds}`;

console.log(&quot;Current date:&quot;, formattedDate);
console.log(&quot;Current time:&quot;, formattedTime);</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-22980258-7625-46c5-b5c0-5fcf9978b4d0.png" class="kg-image" alt="format dates in JavaScript" loading="lazy" width="1582" height="800" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-22980258-7625-46c5-b5c0-5fcf9978b4d0.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-22980258-7625-46c5-b5c0-5fcf9978b4d0.png 1000w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-22980258-7625-46c5-b5c0-5fcf9978b4d0.png 1582w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="advanced-tips-for-date-formatting"><strong>Advanced tips for date formatting</strong></h2><p>When dealing with complex date formatting requirements, we can use third-party libraries such as <a href="https://momentjs.com/">moment.js </a>. Here is a simple usage example:</p><pre><code class="language-html">&lt;!-- Include moment.js --&gt;
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js&quot;&gt;&lt;/script&gt;

&lt;script&gt;
let now = new Date();
// Format date using moment.js
let formattedDate = moment(now).format(&apos;YYYY-MM-DD&apos;);
let formattedTime = moment(now).format(&apos;HH:mm:ss&apos;);
console.log(formattedDate);
console.log(formattedTime);
&lt;/script&gt;</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-8c47008c-cfdb-4eb0-af52-d95cd44d76a0.png" class="kg-image" alt="format dates in JavaScript" loading="lazy" width="1062" height="463" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-8c47008c-cfdb-4eb0-af52-d95cd44d76a0.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-8c47008c-cfdb-4eb0-af52-d95cd44d76a0.png 1000w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-8c47008c-cfdb-4eb0-af52-d95cd44d76a0.png 1062w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="summary">Summary</h2><p>Date formatting is a fundamental skill in <a href="https://zguyun.pan719.com/blog/how-to-copy-an-array-in-javascript/">JavaScript</a> development. By mastering the basic methods and utilizing third-party libraries, we can easily meet various date formatting needs.</p><p></p><p><strong>Reference link:</strong></p><ul><li><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date">JavaScript Date Object Documentation</a></li><li><a href="https://momentjs.com/docs/">Moment.js documentation</a></li><li><a href="https://pan719.cc/">&#x5938;&#x514B;&#x4E91;&#x76D8;&#x8D44;&#x6E90;&#x5206;&#x4EAB;</a></li></ul><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-format-dates-in-javascript/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to format dates in JavaScript?</div><div class="kg-bookmark-description">This article discusses how to format dates in JavaScript, using both native built-in JavaScript methods and third-party libraries such as moment.js.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-22980258-7625-46c5-b5c0-5fcf9978b4d0.png" alt></div></a></figure>]]></content:encoded></item><item><title><![CDATA[How to Add Variables in Regex JavaScript？]]></title><description><![CDATA[One is to use the constructor of the RegExp object, by passing in string variables to create dynamic regular expressions. The other is to combine regular expression literals with variables, directly inserting variables into the regular expression literal to achieve dynamic matching.]]></description><link>https://zguyun.pan719.com/blog/how-to-add-variables-in-regex-javascript/</link><guid isPermaLink="false">65ef2664d393ab1547a69a41</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Regex]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Sun, 20 Apr 2025 23:37:48 GMT</pubDate><content:encoded><![CDATA[<p>In this article, we explore how to incorporate variables into regular expressions in <a href="https://zguyun.pan719.com/blog/how-to-run-a-javascript-file-in-visual-studio-code/">JavaScript</a>. Regular expressions are powerful tools for handling pattern matching and searching within strings, and adding variables can make our regular expressions more flexible and intelligent. In this piece, we delve into how to accomplish this and discuss some common use cases.</p><p></p><h2 id="regular-expression-basics">Regular Expression Basics</h2><p>First, let&apos;s review the basics of regular expressions. In JavaScript, regular expressions consist of metacharacters, quantifiers, character classes, and more. Metacharacters such as &quot;^&quot;, &quot;$&quot;, &quot;.&quot;, etc., represent the beginning, end, or any character in a string to be matched. Quantifiers like &quot;*&quot;, &quot;+&quot;, &quot;?&quot;, etc., specify the quantity of characters to match, while character classes, denoted by square brackets &quot;[]&quot;, match any character from a specified set.</p><p></p><h2 id="methods-to-add-variables-in-regular-expressions">Methods to Add Variables in Regular Expressions</h2><p>So, how do we add variables to regular expressions in JavaScript? There are two common methods. One is to use the constructor of the RegExp object, passing in string variables to create dynamic regular expressions. The other is to combine regular expression literals with variables, directly inserting variables into the regular expression literal to achieve dynamic matching.</p><p></p><h3 id="1using-the-constructor-of-the-regexp-object">1.Using the Constructor of the RegExp Object</h3><p>With the constructor of the RegExp object, we can dynamically create regular expressions, thus adding variables flexibly.</p><p><strong>Example:</strong></p><pre><code class="language-javascript">// Create a string containing a variable
var pattern = &quot;apple&quot;;
var flags = &quot;gi&quot;; // g: global search, i: case insensitive

// Create a dynamic regular expression using the RegExp constructor
var regex = new RegExp(pattern, flags);

// Test the match
var text = &quot;I have an apple and an APPLE.&quot;;
var matches = text.match(regex);
console.log(matches); // [&quot;apple&quot;, &quot;APPLE&quot;]</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-9fb25131-3074-4802-96a7-e1ab1ac8dc0c.png" class="kg-image" alt="Add Variables in Regex JavaScript" loading="lazy" width="1152" height="521" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-9fb25131-3074-4802-96a7-e1ab1ac8dc0c.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-9fb25131-3074-4802-96a7-e1ab1ac8dc0c.png 1000w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-9fb25131-3074-4802-96a7-e1ab1ac8dc0c.png 1152w" sizes="(min-width: 720px) 720px"></figure><p></p><h3 id="2combining-regular-expression-literals-with-variables">2.Combining Regular Expression Literals with Variables</h3><p>We can also directly insert variables into regular expression literals to achieve dynamic matching.</p><p><strong>Example:</strong></p><pre><code class="language-javascript">// Create a string containing a variable
var fruit = &quot;apple&quot;;
var regex = new RegExp(fruit, &quot;gi&quot;); // g: global search, i: case insensitive

// Combine regular expression literal with variable
var text = &quot;I have an apple and an APPLE.&quot;;
var matches = text.match(regex);
console.log(matches); // [&quot;apple&quot;, &quot;APPLE&quot;]</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-3356d97f-6997-4865-ba86-a3924074fd83.png" class="kg-image" alt="Add Variables in Regex JavaScript" loading="lazy" width="1126" height="471" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-3356d97f-6997-4865-ba86-a3924074fd83.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-3356d97f-6997-4865-ba86-a3924074fd83.png 1000w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-3356d97f-6997-4865-ba86-a3924074fd83.png 1126w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Both of these methods enable dynamic regular expressions in JavaScript, allowing us to match content within strings based on the value of variables. The choice between the two depends on personal preference and project requirements.</p><p></p><h2 id="considerations">Considerations</h2><p>When using regular expressions, we need to be careful of special characters that may cause errors, so extra caution is required when constructing dynamic regular expressions. Additionally, we should consider edge cases and boundary conditions to ensure our regular expressions work correctly. It&apos;s best practice to use the constructor of the RegExp object for handling dynamic regular expressions, as it offers more flexibility and safety.</p><p></p><h2 id="conclusion">Conclusion</h2><p>In summary, this article has discussed how to add variables to regular expressions in <a href="https://zguyun.pan719.com/blog/how-to-run-a-javascript-file-in-visual-studio-code/">JavaScript</a> and explored some common use cases. Understanding how to incorporate variables into regular expressions can help us better handle string matching and searching, improving the flexibility and maintainability of our code.</p><p></p><p><strong>References:</strong></p><ul><li>Mozilla Developer Network (MDN) &#xFF1A;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions"><u>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions</u></a></li></ul><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-add-variables-in-regex-javascript/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to Add Variables in Regex JavaScript&#xFF1F;</div><div class="kg-bookmark-description">One is to use the constructor of the RegExp object, by passing in string variables to create dynamic regular expressions. The other is to combine regular expression literals with variables, directly inserting variables into the regular expression literal to achieve dynamic matching.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-9fb25131-3074-4802-96a7-e1ab1ac8dc0c.png" alt></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-disable-back-button-in-browser-using-javascript/">How to Disable Back Button in Browser Using JavaScript&#xFF1F;</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-disable-selection-options-using-javascript/">How to disable selection options using JavaScript?</a></li></ul>]]></content:encoded></item><item><title><![CDATA[Installing Jenkins on Ubuntu 22.04 Server: A Detailed Guide]]></title><description><![CDATA[This guide details the steps to install Jenkins on an Ubuntu server. First, update system packages and install OpenJDK 17. Next, add the official Jenkins repository and update the package index, then install Jenkins.]]></description><link>https://zguyun.pan719.com/blog/installing-jenkins-on-ubuntu-22-04-server/</link><guid isPermaLink="false">667c33c0c66e2e0221866a26</guid><category><![CDATA[Ubuntu]]></category><category><![CDATA[Jenkins]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Sun, 20 Apr 2025 03:31:05 GMT</pubDate><content:encoded><![CDATA[<p>Installing Jenkins on an <a href="https://zguyun.pan719.com/blog/how-to-install-nodejs-and-npm-on-ubuntu-20-04/">Ubuntu</a> server can be accomplished through the following steps:</p><p></p><h2 id="update-system-packages">Update System Packages</h2><p>First, update your package index:</p><pre><code class="language-bash">sudo apt update</code></pre><p></p><h2 id="install-jdk">Install JDK</h2><p>Jenkins requires a Java environment to run. You can install OpenJDK 17, which is currently the recommended version:</p><pre><code class="language-bash">sudo apt install fontconfig openjdk-17-jre</code></pre><p>After installation, check the version:</p><pre><code class="language-bash">java -version</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/06/data-src-image-80046465-81e4-4932-83d2-a2fbd4a6e910.png" class="kg-image" alt="Installing Jenkins on Ubuntu 22.04 Server" loading="lazy" width="1100" height="100" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/06/data-src-image-80046465-81e4-4932-83d2-a2fbd4a6e910.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/06/data-src-image-80046465-81e4-4932-83d2-a2fbd4a6e910.png 1000w, https://zguyun.pan719.com/content/images/2024/06/data-src-image-80046465-81e4-4932-83d2-a2fbd4a6e910.png 1100w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="add-jenkins-repository">Add Jenkins Repository</h2><p>Add the official Jenkins repository to your package manager.First command:</p><pre><code class="language-bash">curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null</code></pre><p>Second command:</p><pre><code class="language-bash">echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list &gt; /dev/null</code></pre><p>Avoid using other signing keys and package repositories (many tutorials lead to errors), as updating the package index may result in errors like:</p><pre><code class="language-bash">E: The repository &apos;https://pkg.jenkins.io/debian-stable binary/ Release&apos; is not signed</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/06/data-src-image-3677d285-44dc-454e-b9b2-8ea4a101046d.png" class="kg-image" alt="Installing Jenkins on Ubuntu 22.04 Server" loading="lazy" width="1280" height="391" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/06/data-src-image-3677d285-44dc-454e-b9b2-8ea4a101046d.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/06/data-src-image-3677d285-44dc-454e-b9b2-8ea4a101046d.png 1000w, https://zguyun.pan719.com/content/images/2024/06/data-src-image-3677d285-44dc-454e-b9b2-8ea4a101046d.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Installing Jenkins may also prompt errors such as:</p><pre><code class="language-bash">E: Package &apos;jenkins&apos; has no installation candidate</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/06/data-src-image-ddcdcd41-2024-4ce4-854c-8ff7d20a849f.png" class="kg-image" alt="Installing Jenkins on Ubuntu 22.04 Server" loading="lazy" width="1092" height="219" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/06/data-src-image-ddcdcd41-2024-4ce4-854c-8ff7d20a849f.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/06/data-src-image-ddcdcd41-2024-4ce4-854c-8ff7d20a849f.png 1000w, https://zguyun.pan719.com/content/images/2024/06/data-src-image-ddcdcd41-2024-4ce4-854c-8ff7d20a849f.png 1092w" sizes="(min-width: 720px) 720px"></figure><p></p><p>For detailed explanations, refer to: <a href="https://www.jenkins.io/blog/2023/03/27/repository-signing-keys-changing/">https://www.jenkins.io/blog/2023/03/27/repository-signing-keys-changing/</a></p><p></p><h2 id="install-jenkins">Install Jenkins</h2><p>First, update the package index again:</p><pre><code class="language-bash">sudo apt update</code></pre><p>Then install Jenkins:</p><pre><code class="language-bash">sudo apt install jenkins</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/06/data-src-image-ea0d560f-f6ff-45b6-aef8-50f7080b4cab.png" class="kg-image" alt="Installing Jenkins on Ubuntu 22.04 Server" loading="lazy" width="1280" height="439" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/06/data-src-image-ea0d560f-f6ff-45b6-aef8-50f7080b4cab.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/06/data-src-image-ea0d560f-f6ff-45b6-aef8-50f7080b4cab.png 1000w, https://zguyun.pan719.com/content/images/2024/06/data-src-image-ea0d560f-f6ff-45b6-aef8-50f7080b4cab.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Check if Jenkins is installed successfully:</p><pre><code class="language-bash">sudo systemctl status jenkins</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/06/data-src-image-bdefc9c6-cb83-4abf-870f-759321d36520.png" class="kg-image" alt="Installing Jenkins on Ubuntu 22.04 Server" loading="lazy" width="1280" height="195" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/06/data-src-image-bdefc9c6-cb83-4abf-870f-759321d36520.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/06/data-src-image-bdefc9c6-cb83-4abf-870f-759321d36520.png 1000w, https://zguyun.pan719.com/content/images/2024/06/data-src-image-bdefc9c6-cb83-4abf-870f-759321d36520.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="start-and-enable-jenkins-service">Start and Enable Jenkins Service</h2><p>Start the Jenkins service and enable it to start on boot:</p><pre><code class="language-bash">sudo systemctl start jenkins
sudo systemctl enable jenkins</code></pre><p></p><h2 id="open-firewall-port">Open Firewall Port</h2><p>Jenkins runs on port 8080 by default. Ensure the firewall allows traffic through this port:</p><pre><code class="language-bash">sudo ufw allow 8080
sudo ufw status</code></pre><p></p><h2 id="access-jenkins">Access Jenkins</h2><p>Open a browser and visit <code>http://your_public_IP:8080</code>. You will see a Jenkins unlock page.</p><p></p><h2 id="unlock-jenkins">Unlock Jenkins</h2><p>The first time you access Jenkins, you need to provide an unlock password. You can find this password with the following command:</p><pre><code class="language-bash">sudo cat /var/lib/jenkins/secrets/initialAdminPassword</code></pre><p>Copy the displayed password and paste it into the Jenkins unlock page in your browser.</p><p></p><h2 id="complete-installation">Complete Installation</h2><p>Follow the Jenkins installation wizard to complete the remaining steps. This includes installing recommended plugins and creating the initial administrator user. With this, you have successfully installed and run Jenkins on your Ubuntu server. You can further configure and manage your Jenkins instance through the Jenkins web interface.</p><p></p><h2 id="uninstall-jenkins">Uninstall Jenkins</h2><p>Use <code>apt</code> or <code>yum</code> (depending on your system) to remove the Jenkins package:</p><pre><code class="language-bash">sudo apt-get remove --purge jenkins
# Or (if using yum)
# sudo yum remove jenkins</code></pre><p></p><h2 id="remove-jenkins-configuration-and-data-files">Remove Jenkins Configuration and Data Files</h2><p>Delete Jenkins configuration and data folders (typically located in <code>/var/lib/jenkins</code> and <code>/etc/jenkins</code>, paths may vary):</p><pre><code class="language-bash">sudo rm -rf /var/lib/jenkins
sudo rm -rf /etc/jenkins
sudo rm -rf /var/log/jenkins
sudo rm -rf /usr/share/jenkins</code></pre><p></p><h2 id="remove-jdk">Remove JDK</h2><p>List installed JDK versions:</p><pre><code class="language-bash">sudo update-alternatives --config java</code></pre><p>Check installed OpenJDK packages:</p><pre><code class="language-bash">dpkg --list | grep openjdk</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/06/data-src-image-743f7ec7-e8c6-416b-8637-570af5bbf92d.png" class="kg-image" alt="Installing Jenkins on Ubuntu 22.04 Server" loading="lazy" width="1280" height="112" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/06/data-src-image-743f7ec7-e8c6-416b-8637-570af5bbf92d.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/06/data-src-image-743f7ec7-e8c6-416b-8637-570af5bbf92d.png 1000w, https://zguyun.pan719.com/content/images/2024/06/data-src-image-743f7ec7-e8c6-416b-8637-570af5bbf92d.png 1280w" sizes="(min-width: 720px) 720px"></figure><p></p><p>Remove OpenJDK packages, for example:</p><pre><code class="language-bash">sudo apt-get remove --purge openjdk-11-jdk-headless
sudo apt-get remove --purge openjdk-11-jre-headless</code></pre><p></p><h2 id="summary">Summary</h2><p>This guide details the steps to install Jenkins on an <a href="https://zguyun.pan719.com/blog/how-to-install-nodejs-and-npm-on-ubuntu-20-04/">Ubuntu</a> server. First, update system packages and install OpenJDK 17. Next, add the official Jenkins repository and update the package index, then install Jenkins. After installation, start and enable the Jenkins service, open firewall port 8080, and access the Jenkins unlock page. Follow the installation wizard to complete plugin installation and administrator creation. Lastly, instructions on how to uninstall Jenkins and its related configuration and data files are provided.</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/installing-jenkins-on-ubuntu-22-04-server/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Installing Jenkins on Ubuntu 22.04 Server: A Detailed Guide</div><div class="kg-bookmark-description">This guide details the steps to install Jenkins on an Ubuntu server. First, update system packages and install OpenJDK 17. Next, add the official Jenkins repository and update the package index, then install Jenkins.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/06/data-src-image-80046465-81e4-4932-83d2-a2fbd4a6e910.png" alt></div></a></figure>]]></content:encoded></item><item><title><![CDATA[How to Access Nested Objects in JavaScript Dynamically]]></title><description><![CDATA[In JavaScript, dynamically accessing nested object properties is a common requirement. We can use square brackets to dynamically access properties, or utilize recursive functions to handle deeply nested properties.]]></description><link>https://zguyun.pan719.com/blog/how-to-access-nested-objects-in-javascript-dynamically/</link><guid isPermaLink="false">65ef2344d393ab1547a69a25</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Nested Objects]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Sun, 20 Apr 2025 02:27:05 GMT</pubDate><content:encoded><![CDATA[<p>Today, we&apos;ll delve into how to dynamically access properties of nested objects in <a href="https://zguyun.pan719.com/blog/how-to-run-a-javascript-file-in-visual-studio-code/">JavaScript</a>. In JavaScript coding, there often arises a need to access object properties dynamically, especially when dealing with nested structures. However, how do we access them dynamically without knowing the property names? That&apos;s precisely what we&apos;ll discuss today.</p><p></p><h2 id="basics-of-nested-object-properties">Basics of Nested Object Properties</h2><p>Firstly, let&apos;s recap what nested objects are. In JavaScript, objects can contain other objects as their properties. For instance, suppose we have an object called <code>person</code>, which has a property named <code>address</code>, and the <code>address</code> property itself is another object containing properties like <code>city</code> and <code>street</code>.</p><pre><code class="language-javascript">const person = {
    name: &apos;John&apos;,
    address: {
        city: &apos;New York&apos;,
        street: &apos;123 Main St&apos;
    }
};</code></pre><p>The conventional way to access nested properties is by using dot notation or square bracket notation. For example, we can access the <code>city</code> property via <code>person.address.city</code>.</p><p></p><h2 id="need-for-dynamically-accessing-nested-object-properties">Need for Dynamically Accessing Nested Object Properties</h2><p>However, in real-world programming, there&apos;s often a requirement to access properties dynamically, meaning determining the property names at runtime. For instance, suppose we need to write a generic function to fetch values from nested objects based on given property names, but we don&apos;t know the exact names of the properties.</p><p></p><h2 id="methods-for-dynamically-accessing-nested-object-properties">Methods for Dynamically Accessing Nested Object Properties</h2><p></p><h3 id="1using-dot-and-bracket-notation">1.<strong>Using Dot and Bracket Notation</strong></h3><p>In JavaScript, we can access object properties using dot or bracket notation. However, using dot notation has a limitation: the property name must be a valid identifier. With bracket notation, we can use strings to access properties, which provides convenience for dynamic property access.</p><pre><code class="language-javascript">const person = {
    name: &apos;John&apos;,
    address: {
        city: &apos;New York&apos;,
        street: &apos;123 Main St&apos;
    }
};

const propertyName = &apos;city&apos;;
console.log(person.address[propertyName]); // Outputs &apos;New York&apos;</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-62caedbd-4902-48f5-827e-457be766a7f6.png" class="kg-image" alt="Access Nested Objects in JavaScript Dynamically" loading="lazy" width="1128" height="504" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-62caedbd-4902-48f5-827e-457be766a7f6.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-62caedbd-4902-48f5-827e-457be766a7f6.png 1000w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-62caedbd-4902-48f5-827e-457be766a7f6.png 1128w" sizes="(min-width: 720px) 720px"></figure><p></p><p>We can see that we can store the property name in a variable and then use that variable within brackets to dynamically access the property.</p><p></p><h3 id="2using-recursive-access-to-nested-properties">2.<strong>Using Recursive Access to Nested Properties</strong></h3><p>Another method for dynamically accessing nested properties is by using recursion. When the structure of the object is recursive, a recursive function can conveniently access nested properties.</p><pre><code class="language-javascript">const person = {
    name: &apos;John&apos;,
    address: {
        city: &apos;New York&apos;,
        street: &apos;123 Main St&apos;
    }
};

function getNestedProperty(obj, props) {
    if (props.length === 1) {
        return obj[props[0]];
    }
    const prop = props.shift();
    return getNestedProperty(obj[prop], props);
}

const propertyPath = [&apos;address&apos;, &apos;city&apos;];
console.log(getNestedProperty(person, propertyPath)); // Outputs &apos;New York&apos;</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-d138a2d8-18c3-45fe-9502-4f7cb7ed5c8c.png" class="kg-image" alt="Access Nested Objects in JavaScript Dynamically" loading="lazy" width="1093" height="499" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-d138a2d8-18c3-45fe-9502-4f7cb7ed5c8c.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-d138a2d8-18c3-45fe-9502-4f7cb7ed5c8c.png 1000w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-d138a2d8-18c3-45fe-9502-4f7cb7ed5c8c.png 1093w" sizes="(min-width: 720px) 720px"></figure><p></p><p>In this example, we&apos;ve written a recursive function <code>getNestedProperty</code>, which takes an object and an array of property paths as parameters. The function recursively dives into nested objects until it finds the final property value.</p><p></p><h3 id="3handling-edge-cases">3.<strong>Handling Edge Cases</strong></h3><p>When accessing properties dynamically, we need to consider scenarios where the property might not exist. In such cases, JavaScript returns <code>undefined</code>. Therefore, proper checks need to be performed before accessing properties to avoid errors.</p><p></p><p><strong>Case Study&#xFF1A;</strong></p><p>Let&apos;s examine a real-world scenario. Suppose we have an object storing the population data of different cities, and we want to write a function to fetch the population based on a given city name.</p><pre><code class="language-javascript">const populationData = {
    NewYork: 8500000,
    LosAngeles: 4000000,
    Chicago: 2700000
};

function getPopulation(city) {
    return populationData[city] || &apos;Population data not found&apos;;
}

console.log(getPopulation(&apos;NewYork&apos;)); // Outputs 8500000
console.log(getPopulation(&apos;London&apos;));   // Outputs &apos;Population data not found&apos;</code></pre><p>This example demonstrates how to dynamically retrieve population data from an object containing city names and corresponding population numbers. Firstly, we have an object named <code>populationData</code>, which contains the population numbers of different cities. Each city name serves as a property of the object, and the corresponding population number serves as the property value.</p><p></p><p>Next, we define a function named <code>getPopulation</code>, which takes a parameter <code>city</code> specifying the city name for which population data is to be retrieved. Within the function body, we dynamically access the property corresponding to the city name in the <code>populationData</code> object using <code>populationData[city]</code>. If the property corresponding to the city is found, the function returns the population number for that city. If the property is not found, JavaScript returns <code>undefined</code>. In such cases, we use the logical OR operator <code>||</code> to provide a fallback value, which is the string <code>&apos;Population data not found&apos;</code>, indicating that the population data for the city is not available.</p><p></p><p>Finally, we call the <code>getPopulation</code> function to retrieve the population number for a specific city and print the result to the console. In this example, <code>getPopulation(&apos;NewYork&apos;)</code> will return <code>8500000</code> because the <code>populationData</code> object contains the <code>NewYork</code> property with a population number of <code>8500000</code>. On the other hand, <code>getPopulation(&apos;London&apos;)</code> will return <code>&apos;Population data not found&apos;</code> because the <code>populationData</code> object does not contain the <code>London</code> property, indicating that population data for London is not available.</p><p></p><h2 id="conclusion">Conclusion</h2><p>In <a href="https://zguyun.pan719.com/blog/how-to-run-a-javascript-file-in-visual-studio-code/">JavaScript</a>, dynamically accessing nested object properties is a common requirement. We can utilize bracket notation for dynamic property access or employ recursive functions to handle deeply nested properties. However, it&apos;s crucial to consider scenarios where properties might not exist while writing code to prevent errors. This concludes our discussion on dynamically accessing nested object properties in JavaScript.</p><p></p><p><strong>References:</strong></p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects">Mozilla Developer Network (MDN) - Working with objects</a></li><li><a href="https://jsnoteclub.com/blog/how-to-access-nested-object-in-javascript-dynamically/">JS Note Club - How to access nested object in JavaScript dynamically</a></li></ul><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-access-nested-objects-in-javascript-dynamically/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to Access Nested Objects in JavaScript Dynamically</div><div class="kg-bookmark-description">In JavaScript, dynamically accessing nested object properties is a common requirement. We can use square brackets to dynamically access properties, or utilize recursive functions to handle deeply nested properties.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-62caedbd-4902-48f5-827e-457be766a7f6.png" alt></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-add-variables-in-regex-javascript/">How to Add Variables in Regex JavaScript&#xFF1F;</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-disable-back-button-in-browser-using-javascript/">How to Disable Back Button in Browser Using JavaScript&#xFF1F;</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How to compare date sizes in JavaScript?]]></title><description><![CDATA[This article explains how to compare date and time in JavaScript. JavaScript offers various methods to represent date and time, including Date objects, timestamps, and date-time strings.]]></description><link>https://zguyun.pan719.com/blog/how-to-compare-date-sizes-in-javascript/</link><guid isPermaLink="false">65f70aa7d393ab1547a69bcd</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Data]]></category><category><![CDATA[compare date sizes]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Sun, 20 Apr 2025 01:29:05 GMT</pubDate><content:encoded><![CDATA[<p>Handling dates is a very common and important task, whether it&apos;s scheduling meetings, devising plans, or tracking time in transactions. We often need to compare dates and times. This article will introduce how to compare dates and times in <a href="https://zguyun.pan719.com/blog/how-to-copy-an-array-in-javascript/">JavaScript</a>, as well as tips and precautions in practical applications.</p><p></p><h2 id="date-and-time-representation-in-javascript"><strong>Date and time representation in JavaScript</strong></h2><p>JavaScript provides a Date object to handle dates and times. We can use it to create, manipulate, and represent dates and times.</p><pre><code class="language-javascript">// Create Date objects
let currentDate = new Date();
let futureDate = new Date(&apos;2024-12-31&apos;);

// Get date and time
console.log(currentDate); // Current date and time
console.log(futureDate); // Specified date and time</code></pre><p></p><h2 id="date-comparison-methods-in-javascript"><strong>Date comparison methods in JavaScript</strong></h2><p>JavaScript provides multiple ways to represent dates and times, including Date objects, timestamps, and datetime strings. Details are as follows.</p><p></p><h3 id="1-use-comparison-operators-directly-%EF%BC%88%E3%80%81%E3%80%81%E3%80%81%EF%BC%89">1 <strong>. Use comparison operators directly &#xFF08;&gt;&#x3001;&lt;&#x3001;&gt;=&#x3001;&lt;=&#xFF09;</strong></h3><p>The Date object in JavaScript can be directly compared using comparison operators. When compared, the Date object is automatically converted to a millisecond value (the number of milliseconds since January 1, 1970).</p><pre><code class="language-javascript">const date1 = new Date(&apos;2024-03-17&apos;);
const date2 = new Date(&apos;2024-03-18&apos;);

if (date1 &gt; date2) {
    console.log(&apos;date1 is later than date2&apos;);
} else if (date1 &lt; date2) {
    console.log(&apos;date1 is earlier than date2&apos;);
} else {
    console.log(&apos;The two dates are equal&apos;);
}</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-2aefa5ac-6192-48a4-8912-f99f218bffd4.png" class="kg-image" alt="compare date sizes in JavaScript" loading="lazy" width="946" height="484" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-2aefa5ac-6192-48a4-8912-f99f218bffd4.png 600w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-2aefa5ac-6192-48a4-8912-f99f218bffd4.png 946w" sizes="(min-width: 720px) 720px"></figure><p></p><h3 id="2-compare-date-parts-ignore-time">2. <strong>Compare date parts (ignore time)</strong></h3><p>If you only want to compare two dates without considering the time part, you can set the time part to the same value first and then compare them.</p><pre><code class="language-javascript">let date1 = new Date(&apos;2023-03-25T00:00:00&apos;);
let date2 = new Date(&apos;2023-03-26T00:00:00&apos;);

console.log(date1 &lt; date2); // true
console.log(date1 &gt;= date2); // false</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-83edfa9b-75c3-4b9a-9a92-85b08e11cb32.png" class="kg-image" alt="compare date sizes in JavaScript" loading="lazy" width="953" height="390" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-83edfa9b-75c3-4b9a-9a92-85b08e11cb32.png 600w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-83edfa9b-75c3-4b9a-9a92-85b08e11cb32.png 953w" sizes="(min-width: 720px) 720px"></figure><p>Alternatively, convert the time to a string in YYYY-MM-DD format and compare these strings:</p><pre><code class="language-javascript">let date1 = new Date(&apos;2023-03-25&apos;).toISOString().split(&apos;T&apos;)[0];
let date2 = new Date(&apos;2023-03-26&apos;).toISOString().split(&apos;T&apos;)[0];

console.log(date1 &lt; date2); // true
console.log(date1 &gt; date2); // false</code></pre><p></p><h3 id="3-use-dateparse">3. <strong>Use Date.parse ()</strong></h3><p>Use the <code>Date.parse () </code>method to parse the date string, convert it to a millisecond value, and then compare.</p><pre><code class="language-javascript">let date1 = Date.parse(&apos;2023-03-25&apos;);
let date2 = Date.parse(&apos;2023-03-26&apos;);

console.log(date1 &lt; date2); // true
console.log(date1 &gt; date2); // false</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-b1fb038c-80c6-43f1-aa17-fcc5624b3a27.png" class="kg-image" alt="compare date sizes in JavaScript" loading="lazy" width="1041" height="415" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/data-src-image-b1fb038c-80c6-43f1-aa17-fcc5624b3a27.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/data-src-image-b1fb038c-80c6-43f1-aa17-fcc5624b3a27.png 1000w, https://zguyun.pan719.com/content/images/2024/03/data-src-image-b1fb038c-80c6-43f1-aa17-fcc5624b3a27.png 1041w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="comparative-skills-in-practical-application-scenarios"><strong>Comparative skills in practical application scenarios</strong></h2><p>In practical applications, we may need to compare the order of dates or check if they are equal.</p><pre><code class="language-javascript">// Compare the order of two dates
if (futureDate.getTime() &gt; currentDate.getTime()) {
    console.log(&apos;futureDate is later than currentDate&apos;);
} else if (futureDate.getTime() &lt; currentDate.getTime()) {
    console.log(&apos;futureDate is earlier than currentDate&apos;);
} else {
    console.log(&apos;The two date times are equal&apos;);
}

// Check if two dates are equal
if (futureDate.getTime() === currentDate.getTime()) {
    console.log(&apos;The two date times are equal&apos;);
} else {
    console.log(&apos;The two date times are not equal&apos;);
}</code></pre><p></p><h2 id="summary"><strong>Summary</strong></h2><p>This article introduces various methods for comparing dates and times, including using Date objects, timestamps, and datetime strings. Different methods are suitable for different scenarios, and developers can choose the appropriate method according to their needs. In the future, with the development of <a href="https://zguyun.pan719.com/blog/how-to-copy-an-array-in-javascript/">JavaScript</a> technology, more convenient date and time processing tools and methods may emerge.</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-compare-date-sizes-in-javascript/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to compare date sizes in JavaScript?</div><div class="kg-bookmark-description">This article explains how to compare date and time in JavaScript. JavaScript offers various methods to represent date and time, including Date objects, timestamps, and date-time strings.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/03/data-src-image-2aefa5ac-6192-48a4-8912-f99f218bffd4.png" alt></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-format-dates-in-javascript/">How to format dates in JavaScript?</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How to convert string to Buffer in JavaScript?]]></title><description><![CDATA[This article introduces two methods for converting strings to Buffers in JavaScript: using the Buffer class and using the TextEncoder class.]]></description><link>https://zguyun.pan719.com/blog/how-to-convert-string-to-buffer-in-javascript/</link><guid isPermaLink="false">65f0720cd393ab1547a69aad</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Buffer]]></category><category><![CDATA[String]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Sun, 20 Apr 2025 00:07:05 GMT</pubDate><content:encoded><![CDATA[<p>Sometimes we need to convert strings to buffers in <a href="https://zguyun.pan719.com/blog/how-to-add-variables-in-regex-javascript/">JavaScript</a>, which may involve scenarios such as network transmission and file processing. This article will share with you how to implement this operation in JavaScript.</p><p></p><h2 id="1-what-is-buffer">1. <strong>What is Buffer?</strong></h2><p>First, let&apos;s understand what Buffer is. Simply put, Buffer is an object used to process binary data. In JavaScript, string is a sequence of Unicode characters, while Buffer is a sequence of bytes, which makes Buffer very efficient in processing binary data.</p><p></p><h2 id="2-difference-between-string-and-buffer">2. <strong>Difference between string and buffer</strong></h2><p>Well, to better understand, let&apos;s compare the storage methods of string and Buffer in memory. String is stored in units of <strong>characters </strong>, while Buffer is stored in units of <strong>bytes </strong>. So, in some cases, we need to convert string to Buffer to better handle data.</p><p></p><p>When we talk about strings and buffers, we are actually discussing the storage method of data in memory, which is very important because it directly affects how we process data. Strings are stored in character units, which means that each character occupies a certain amount of Memory Space, and the size of this Memory Space depends on the encoding of the character. For example, for English characters, usually one character occupies one byte of Memory Space; but for some non-English characters or special characters, one character may occupy multiple bytes of Memory Space. This storage method makes strings very convenient when processing text data, and we can easily perform various operations on strings, such as concatenation, interception, and searching.</p><p></p><p>Buffer is completely different. It stores data in bytes. That is to say, Buffer stores the original byte sequence of data, not the character sequence, which makes Buffer very efficient in processing binary data. For example, when we need to process files, network data streams, or perform encryption and decryption operations, we usually need to use Buffer. Because in these scenarios, we are more concerned about the original byte content of the data, not the character encoding.</p><p></p><p>Therefore, when we need to process binary data in JavaScript, such as file operations, network transfers, or encryption and decryption operations, we need to convert strings to buffers. Because in these cases, we are more concerned about the byte content of the data than the character encoding.</p><p></p><h2 id="3-the-method-of-converting-string-to-buffer-in-javascript">3. The <strong>method of converting string to Buffer in JavaScript</strong></h2><h2 id></h2><p>Now let&apos;s see how to convert string to Buffer in <a href="https://zguyun.pan719.com/blog/how-to-add-variables-in-regex-javascript/">JavaScript</a>. First, we have a simple method, which is to use the Buffer class.</p><p></p><h3 id="method-1-use-the-buffer-class"><strong>Method 1: Use the Buffer class</strong></h3><p>We can use the <code>Buffer.from () </code>method to do this. This method takes a string as a parameter and returns a corresponding Buffer object. Let&apos;s look at an example:</p><pre><code class="language-javascript">const str = &apos;Hello, world!&apos;;
const buf = Buffer.from(str);
console.log(buf);</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/image-6.png" class="kg-image" alt="convert string to Buffer in JavaScript" loading="lazy" width="1328" height="483" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/image-6.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/image-6.png 1000w, https://zguyun.pan719.com/content/images/2024/03/image-6.png 1328w" sizes="(min-width: 720px) 720px"></figure><p>In this way, we convert string to Buffer, very simple!</p><p></p><h3 id="method-2-use-textencoder"><strong>Method 2: Use TextEncoder</strong></h3><p>Another way is to use the TextEncoder class. It can encode the string as Uint8Array, and then we can convert it to Buffer through the <code>Buffer.from () </code>method. Take a look at the code:</p><pre><code class="language-javascript">const encoder = new TextEncoder();
const str = &apos;Hello, world!&apos;;
const uint8Array = encoder.encode(str);
const buf = Buffer.from(uint8Array);
console.log(buf);</code></pre><figure class="kg-card kg-image-card"><img src="https://zguyun.pan719.com/content/images/2024/03/image-7.png" class="kg-image" alt="convert string to Buffer in JavaScript" loading="lazy" width="1218" height="442" srcset="https://zguyun.pan719.com/content/images/size/w600/2024/03/image-7.png 600w, https://zguyun.pan719.com/content/images/size/w1000/2024/03/image-7.png 1000w, https://zguyun.pan719.com/content/images/2024/03/image-7.png 1218w" sizes="(min-width: 720px) 720px"></figure><p>This can also convert string to Buffer.</p><p></p><h2 id="4-performance-and-applicability-comparison">4. <strong>Performance and applicability comparison</strong></h2><p>So, which of these two methods is better? It depends on your needs and performance requirements. Generally speaking, if you simply convert string to Buffer, using the Buffer class will be more convenient. But if you need more coding control, TextEncoder may be more suitable for you.</p><p></p><h2 id="summary">Summary</h2><p>Overall, no matter which method you choose, converting string to buffer is relatively simple. Choosing the appropriate method based on your needs and performance requirements is the most important.</p><p></p><p><strong>Reference link:</strong></p><ul><li><a href="https://nodejs.org/dist/latest-v16.x/docs/api/buffer.html">Node.js official documentation: Buffer class</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder">MDN Web Documentation: TextEncoder</a></li></ul><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-convert-string-to-buffer-in-javascript/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to convert string to Buffer in JavaScript?</div><div class="kg-bookmark-description">This article introduces two methods for converting strings to Buffers in JavaScript: using the Buffer class and using the TextEncoder class.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://zguyun.pan719.com/content/images/2024/03/image-6.png" alt></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-add-minutes-to-date-in-javascript/">How to Add Minutes to Date in JavaScript?</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-check-if-two-arrays-have-equal-values-in-javascript/">How to check if two arrays have equal values in JavaScript?</a></li></ul>]]></content:encoded></item><item><title><![CDATA[How to bold text in JavaScript?]]></title><description><![CDATA[This article discusses how to make text bold in JavaScript. To achieve text bolding, you simply need to select the relevant elements and then apply the appropriate styling, such as setting the font weight to 'bold'.]]></description><link>https://zguyun.pan719.com/blog/how-to-bold-text-in-javascript/</link><guid isPermaLink="false">65f7096ad393ab1547a69bbb</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[bold text]]></category><dc:creator><![CDATA[Autumn]]></dc:creator><pubDate>Sat, 19 Apr 2025 23:07:05 GMT</pubDate><content:encoded><![CDATA[<p>In web design, making text bold is crucial for highlighting key information and enhancing the visual effect of the page. However, sometimes we need to dynamically manipulate page text through <a href="https://zguyun.pan719.com/blog/how-to-copy-an-array-in-javascript/">JavaScript</a>. What should we do in this case? Don&apos;t worry, today we will discuss how to bold text in JavaScript.</p><p></p><h2 id="1-basic-method-using-html-tags">1<strong>. Basic method: using HTML tags</strong></h2><p>First of all, we have to admit that the simplest way to bold is to use HTML tags, such as <code>&lt; b &gt; </code>or <code>&lt; strong &gt; </code>tags. In static HTML, you can use these tags directly where you need to bold. But the problem is that when we need to dynamically generate content in JavaScript, this method seems a bit inadequate.</p><pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Bold Text Example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;p&gt;This is a &lt;b&gt;bold&lt;/b&gt; text.&lt;/p&gt;
    &lt;p&gt;This is another &lt;strong&gt;bold&lt;/strong&gt; text.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre><p></p><h2 id="2-manipulating-dom-elements-with-javascript">2<strong>. Manipulating DOM elements with JavaScript</strong></h2><p>Now it&apos;s JavaScript&apos;s turn! JavaScript is a language that can manipulate the DOM (Document Object Model), allowing us to dynamically change the page content after the page is loaded. You can use JavaScript to select elements on the page and perform various operations on them, such as modifying styles, changing content, and so on. Therefore, to achieve text bold, you only need to select the corresponding elements and set appropriate styles for them.</p><pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Bold Text Example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;p id=&quot;text&quot;&gt;This is a piece of ordinary text.&lt;/p&gt;
    &lt;button onclick=&quot;makeTextBold()&quot;&gt;Click to Bold&lt;/button&gt;

    &lt;script&gt;
        function makeTextBold() {
            const textElement = document.getElementById(&apos;text&apos;);
            textElement.style.fontWeight = &apos;bold&apos;;
        }
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre><p></p><h2 id="3-use-css-to-implement-text-bold"><strong>3. Use CSS to implement text bold</strong></h2><p>Perhaps you may ask, is there a more elegant way to achieve it? The answer is yes! CSS style sheets are our good helper. By adding specific CSS classes to text, we can dynamically control the style of text in JavaScript, including bold. Simply manipulating the class attribute of the element through JavaScript can make the text bold.</p><pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Bold Text Example&lt;/title&gt;
    &lt;style&gt;
        .bold-text {
            font-weight: bold;
        }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;p id=&quot;text&quot;&gt;This is a piece of ordinary text.&lt;/p&gt;
    &lt;button onclick=&quot;makeTextBold()&quot;&gt;Click to Bold&lt;/button&gt;

    &lt;script&gt;
        function makeTextBold() {
            const textElement = document.getElementById(&apos;text&apos;);
            textElement.classList.add(&apos;bold-text&apos;);
        }
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre><p></p><h2 id="summary"><strong>Summary</strong></h2><p>In short, it is not difficult to implement text bold in web pages through <a href="https://zguyun.pan719.com/blog/how-to-copy-an-array-in-javascript/">JavaScript</a>. Whether it is directly manipulating DOM elements or using CSS styles, we have multiple choices. The most important thing is to choose the appropriate method according to the specific situation and needs. I hope this article is helpful to you and I hope you continue to explore more possibilities in JavaScript and web design!</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://zguyun.pan719.com/blog/how-to-bold-text-in-javascript/"><div class="kg-bookmark-content"><div class="kg-bookmark-title">How to bold text in JavaScript?</div><div class="kg-bookmark-description">This article discusses how to make text bold in JavaScript. To achieve text bolding, you simply need to select the relevant elements and then apply the appropriate styling, such as setting the font weight to &#x2018;bold&#x2019;.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://zguyun.pan719.com/content/images/size/w256h256/2023/12/logo-1.png" alt><span class="kg-bookmark-author">ZGY</span><span class="kg-bookmark-publisher">Autumn</span></div></div></a></figure><p></p><p>Learn more:</p><ul><li><a href="https://zguyun.pan719.com/blog/how-to-compare-date-sizes-in-javascript/">How to compare date sizes in JavaScript?</a></li><li><a href="https://zguyun.pan719.com/blog/how-to-format-dates-in-javascript/">How to format dates in JavaScript?</a></li></ul>]]></content:encoded></item></channel></rss>