<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: off.tokyo</title>
    <description>The latest articles on DEV Community by off.tokyo (@off_tokyo_).</description>
    <link>https://dev.to/off_tokyo_</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F620462%2Fcb7a396d-6de5-4430-840d-6cc8489ab433.jpeg</url>
      <title>DEV Community: off.tokyo</title>
      <link>https://dev.to/off_tokyo_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/off_tokyo_"/>
    <language>en</language>
    <item>
      <title>HTTP status codes explained for beginners</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Sat, 26 Jun 2021 05:01:42 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/http-status-codes-explained-for-beginners-42h</link>
      <guid>https://dev.to/off_tokyo_/http-status-codes-explained-for-beginners-42h</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uizNqjgY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19b7e2vbqp32g91rs7b3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uizNqjgY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19b7e2vbqp32g91rs7b3.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an HTTP status code?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Strictly speaking, the status code of an HTTP response&lt;/li&gt;
&lt;li&gt;A three-digit numeric code that indicates the meaning of the response from the server&lt;/li&gt;
&lt;li&gt;Indicates whether a specific HTTP request has been successfully completed&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  HTTP response
&lt;/h2&gt;

&lt;p&gt;Response messages can be divided into three main types of information&lt;/p&gt;

&lt;p&gt;-Status lines&lt;br&gt;
-HTTP response headers&lt;br&gt;
-HTTP response body&lt;/p&gt;
&lt;h2&gt;
  
  
  The status code is in the first line of the header
&lt;/h2&gt;

&lt;p&gt;The status code is in the first line of the header, in the status line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 200 OK
Date: Sat, 22 Feb 2020 08:09:30 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Server: nginx
ETag: "e287c729017cc9785487098b6b103af6"
Cache-Control: max-age=0, private, must-revalidate
X-UA-Compatible: IE=Edge,chrome=1
X-Runtime: 0.003487
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The status line contains a protocol and a text phrase as well as the status code discussed here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 200 OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Protocol: HTTP/1.1&lt;/li&gt;
&lt;li&gt;Status code: 200&lt;/li&gt;
&lt;li&gt;Text phrase: OK&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The header is further subdivided, but not in this case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--teO6ALLU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y77qvk3ef9o43hphr979.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--teO6ALLU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y77qvk3ef9o43hphr979.png" alt="https___media.prod.mdn.mozit.cloud_attachments_2016_08_31_13823_0a5a12cef96993c8d6fa843d7230a9d9_HTTP_Response_Headers2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Status codes are divided into five classes&lt;/p&gt;

&lt;p&gt;100s = information response&lt;br&gt;
200s = success response&lt;br&gt;
300s = Redirect&lt;br&gt;
400s = Client error&lt;br&gt;
500s = Server error&lt;/p&gt;

&lt;p&gt;Below is an extract of a summary of typical status codes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Number 100 Information response
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Indicates that processing is continuing.&lt;/li&gt;
&lt;li&gt;The client can either continue with the request or follow the server's instructions to update the protocol and resend&lt;/li&gt;
&lt;li&gt;The 100s are not often used as there is no definition of a 1xx number in the HTTP/1.0 convention&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  100 Continue 
&lt;/h3&gt;

&lt;p&gt;The server has not rejected the request. The client can continue the request.&lt;/p&gt;

&lt;h3&gt;
  
  
  101 Switching Protocols 
&lt;/h3&gt;

&lt;p&gt;The server is requesting a protocol switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  200 units Successful response
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The most common status code returned on success&lt;/li&gt;
&lt;li&gt;The requested operation was successful and the specified data was successfully retrieved.&lt;/li&gt;
&lt;li&gt;GET: the body contains the resource&lt;/li&gt;
&lt;li&gt;PUT, POST: The body contains the result of the operation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  201 Created
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;POST, PUT: The request was successful and the resource was created&lt;/li&gt;
&lt;li&gt;In the case of POST, the URI is included in the Location header of the response&lt;/li&gt;
&lt;li&gt;New user registration, image upload, DB table addition, etc.&lt;/li&gt;
&lt;li&gt;The body often contains the newly created resource, but it doesn't have to contain anything in particular.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  202 Accepted
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The request has been accepted, but has not yet been processed.&lt;/li&gt;
&lt;li&gt;Returned when there is asynchronous processing to be done on the server side, such as file format conversion, push notification requests, batch processing, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  204 No Content
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Returned when the response body is empty.&lt;/li&gt;
&lt;li&gt;Returned when data is deleted using DELETE&lt;/li&gt;
&lt;li&gt;Returned when the form content has been submitted using POST, but the screen has not been updated.&lt;/li&gt;
&lt;li&gt;If the data was updated correctly with PUT or PATCH&lt;/li&gt;
&lt;li&gt;Some people think it shouldn't be used for anything other than DELETE.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  205 Reset Content
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Returned when the user agent screen is reset.&lt;/li&gt;
&lt;li&gt;As 204, no response body.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  300 Multiple Choices Redirect
&lt;/h2&gt;

&lt;h3&gt;
  
  
  300 Multiple Choices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Indicates that there are multiple responses to a request.&lt;/li&gt;
&lt;li&gt;The user agent or user is presented with HTML that links to the choices and the user chooses one of them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  301 Moved Permanently
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The URL of the requested resource has been permanently changed.&lt;/li&gt;
&lt;li&gt;such as a website move or a redirect from HTTP to HTTPS.&lt;/li&gt;
&lt;li&gt;The Location header indicates the URL to move to.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  302 Found
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The URL of the requested resource has been temporarily changed.&lt;/li&gt;
&lt;li&gt;The destination URL is shown in the Location header.&lt;/li&gt;
&lt;li&gt;In practice, this is more likely to be used for 303, which has been redefined as 307 and is now deprecated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  303 See Other
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Indicates that the requested resource can be retrieved at a different URI.&lt;/li&gt;
&lt;li&gt;The Location header indicates the URL to go to.&lt;/li&gt;
&lt;li&gt;Used to redirect to a result page in response to a POST from a browser form.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  307 Temporary Redirect
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Temporary Redirect&lt;/li&gt;
&lt;li&gt;This is a redefinition of the 302 due to rampant misuse.&lt;/li&gt;
&lt;li&gt;The Location header shows the URL to which the user is redirected.&lt;/li&gt;
&lt;li&gt;User agents should not change the HTTP method they use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  308 Permanent Redirect
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Permanent Redirects&lt;/li&gt;
&lt;li&gt;Redefined due to rampant non-standard usage of 301.&lt;/li&gt;
&lt;li&gt;The Location header indicates the URL to go to.&lt;/li&gt;
&lt;li&gt;User agents must not change the HTTP method they use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  400 Client Error
&lt;/h2&gt;

&lt;h3&gt;
  
  
  400 Bad Request
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Bad request&lt;/li&gt;
&lt;li&gt;A bad client request, e.g. using a method that is not defined, or with incorrect parameters.&lt;/li&gt;
&lt;li&gt;Also used when no other status code is available to indicate a proper client error.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  401 Unauthorized
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Authentication errors&lt;/li&gt;
&lt;li&gt;Wrong ID or password on a page that requires login.&lt;/li&gt;
&lt;li&gt;The request does not contain the required Authorization header.&lt;/li&gt;
&lt;li&gt;Token expired, corrupted or otherwise invalid.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  403 Forbidden
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Authorization error&lt;/li&gt;
&lt;li&gt;The client is not authorised to access the site, for example, because it is not authorised, and the response from the server is rejected&lt;/li&gt;
&lt;li&gt;Used when the server can only be accessed from a specific IP address.&lt;/li&gt;
&lt;li&gt;Unlike the 401, the client is still identified.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  404 Not Found
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The requested resource does not exist.&lt;/li&gt;
&lt;li&gt;One of the most common error status codes found on the web.&lt;/li&gt;
&lt;li&gt;More information is needed to determine if the URI itself does not exist, or if the resource to be retrieved does not exist.&lt;/li&gt;
&lt;li&gt;Sometimes a 404 is returned instead of a 403 to hide the existence of the resource from unauthorized clients.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  405 Method Not Allowed
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;HTTP method not allowed although endpoint exists.&lt;/li&gt;
&lt;li&gt;If you try to use POST with a search API that is accessible via GET&lt;/li&gt;
&lt;li&gt;If the API prohibits DELETE of a resource.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  408 Request Timeout
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The request did not complete within the specified time.&lt;/li&gt;
&lt;li&gt;Commonly used by Chrome, Firefox and other browsers that use the HTTP pre-connect feature to speed up browsing.&lt;/li&gt;
&lt;li&gt;Occurs when the connection speed of the line is slow.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  409 Conflict
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Occurs when there is a resource conflict&lt;/li&gt;
&lt;li&gt;When you try to register a user with an already existing email address or the same ID.&lt;/li&gt;
&lt;li&gt;If you try to delete a non-empty directory or rename a resource to one that is already in use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  410 Gone
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;When the requested content has been permanently removed from the server and there is no forwarding address.&lt;/li&gt;
&lt;li&gt;Unlike 404, this means that the content once existed but no longer exists.&lt;/li&gt;
&lt;li&gt;Intended for use in limited-time promotions.&lt;/li&gt;
&lt;li&gt;APIs that handle user information and return 410 may be considered problematic from the perspective of protecting personal information (the information that the user has deleted is retained ≈ the user has not completely deleted).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  413 Payload Too Large
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Indicates that the request header or body exceeds the limit set by the server.&lt;/li&gt;
&lt;li&gt;The server will either close the connection or send an error message to the server (e.g. if the file upload exceeds the allowed size).&lt;/li&gt;
&lt;li&gt;The server will close the connection or return a Retry-After header.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  414 URI Too Long
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The URI requested by the client is longer than the server can handle.&lt;/li&gt;
&lt;li&gt;The server will close the connection or return a Retry-After header.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  415 Unsupported Media Type
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The server does not support the media type (Content-Type) of the requested data, and the server rejected the request.&lt;/li&gt;
&lt;li&gt;XML was sent to an API that only accepts JSON requests, or an attempt was made to upload an image that is not in a supported image format.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  429 Too Many Requests
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Returned when the number of accesses exceeds the allowed limit.&lt;/li&gt;
&lt;li&gt;New status code defined in RFC 6585 in 2012.&lt;/li&gt;
&lt;li&gt;A large number of requests have been sent that exceed the rate limit within a certain time period (e.g. an API request limit of 60 requests per minute).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  500 Server Error
&lt;/h2&gt;

&lt;h3&gt;
  
  
  500 Internal Server Error
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Some kind of error occurred on the server side and the response is not normal.
-The error message "Something went wrong" is often returned and cannot be resolved by the client.
-It is also used when there is no other appropriate error code.
-You may be able to find the cause by looking at the server's error log&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  502 Bad Gateway
&lt;/h3&gt;

&lt;p&gt;-There is a problem with the gateway or proxy.&lt;br&gt;
-The server acting as the gateway has received an invalid response.&lt;/p&gt;

&lt;h3&gt;
  
  
  503 Service Unavailable
&lt;/h3&gt;

&lt;p&gt;-The server is not ready to process the request.&lt;br&gt;
-The server is down due to temporary heavy traffic or maintenance.&lt;br&gt;
-In the case of maintenance, the Retry-After header can include an estimated restart time (in seconds).&lt;/p&gt;

&lt;h3&gt;
  
  
  504 Gateway Timeout
&lt;/h3&gt;

&lt;p&gt;-The server acting as the gateway did not receive a response within the specified time.&lt;br&gt;
-This can be a temporary DNS anomaly due to site migration etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  505 HTTP Version Not Supported
&lt;/h3&gt;

&lt;p&gt;-The server does not support the version of the HTTP protocol requested.&lt;br&gt;
-The current protocol is HTTP/2.&lt;br&gt;
-HTTP/2 Overview | Web Fundamentals | Google Developers&lt;/p&gt;

&lt;h2&gt;
  
  
  reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://off.tokyo/blog/explanation-of-http-status-codes/"&gt;Explanation of HTTP status codes&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to get the id of a dynamic route with Nextjs getServerSideProps</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Sat, 26 Jun 2021 01:08:12 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/how-to-get-the-id-of-a-dynamic-route-with-nextjs-getserversideprops-56kh</link>
      <guid>https://dev.to/off_tokyo_/how-to-get-the-id-of-a-dynamic-route-with-nextjs-getserversideprops-56kh</guid>
      <description>&lt;h2&gt;
  
  
  Things to do
&lt;/h2&gt;

&lt;p&gt;Normally, in order to get the id 1 in Next.js dynamic routing (post/1), you can write the following to get the value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How do I get this in getServerSideProps?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getServerSideProps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can do the following to get it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getServerSideProps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reference.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/61222726/dynamic-routing-with-%20getserversideprops-in-nextjs"&gt;Dynamic routing with getServerSideProps in Nextjs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://off.tokyo/blog/dynamic-routing-with-getserversideprops-in-nextjs/"&gt;How to get the id of dynamic routing with getServerSideProps in Nextjs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
    </item>
    <item>
      <title>How to validate with react-datepicker</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Wed, 16 Jun 2021 02:31:05 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/how-to-validate-with-react-datepicker-3jog</link>
      <guid>https://dev.to/off_tokyo_/how-to-validate-with-react-datepicker-3jog</guid>
      <description>&lt;p&gt;Using react-datepicker, you can easily create a datepicker.&lt;/p&gt;

&lt;p&gt;In this article, I'll show you how to validate with react-datepicker.&lt;/p&gt;

&lt;p&gt;Specifically, let's consider a situation where you need to enter your date of birth, for example, when registering user information for a web service.&lt;/p&gt;

&lt;p&gt;The idea is to use a validation to tell the user that they must be at least 15 years old to register.&lt;/p&gt;

&lt;p&gt;How to validate with react-datepicker&lt;/p&gt;

&lt;p&gt;First, suppose we have a DatePicker component like the one below, and we use the argument maxDate.&lt;/p&gt;

&lt;p&gt;If you have a DatePicker component like the one below, you can use the argument "maxDate" to make it impossible to set a date before ●●●●.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;DatePicker&lt;/span&gt;
&lt;span class="nx"&gt;selected&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;startDate&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;maxDate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;TimeValidation&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's look at TimeValidation and see what happens.&lt;/p&gt;

&lt;p&gt;By specifying 15 years ago (5475 days ago) from today's date, you can only select dates from earlier dates.&lt;/p&gt;

&lt;p&gt;For example, if the year is 2021, only people born before 2006 will be able to enter their date of birth.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I-2uHMli--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d51xq3666gvtsv939rmm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I-2uHMli--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d51xq3666gvtsv939rmm.png" alt="TimeValidation"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;initialDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TimeValidation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;initialDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initialDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getDate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5475&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;There are many other arguments that can be used in react-datepicker, so please look into them.&lt;/p&gt;

&lt;p&gt;I refer to the following article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.freakyjolly.com/react-"&gt;React Datepicker and Timepicker Component with Validation using react-datepicker Example Application&lt;/a&gt; datepicker-using-react-datepicker/)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://off.tokyo/blog/react-datepicker-en/"&gt;How to validate with react-datepicker off.tokyo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
    </item>
    <item>
      <title>How to register image verification in Stripe Connect | Identity verification for child accounts | Node.js</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Sun, 06 Jun 2021 09:40:08 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/how-to-register-image-verification-in-stripe-connect-identity-verification-for-child-accounts-node-js-410a</link>
      <guid>https://dev.to/off_tokyo_/how-to-register-image-verification-in-stripe-connect-identity-verification-for-child-accounts-node-js-410a</guid>
      <description>&lt;p&gt;&lt;a href="https://off.tokyo/blog/stripe-connect-img-add/"&gt;Web media for tech lovers | off.tokyo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I started to make &lt;a href="https://meee.work"&gt;a service for skill-sharing&lt;/a&gt; in 2020, but it was completely neglected.&lt;/p&gt;

&lt;p&gt;But I've recently started developing it again.&lt;/p&gt;

&lt;p&gt;It seems that my passion for the market of person-to-person trading hasn't been crushed yet.&lt;/p&gt;

&lt;p&gt;Well, that's not really the point...&lt;/p&gt;

&lt;p&gt;A lot of code was stuck, and the Stripe area wasn't working anymore.&lt;/p&gt;

&lt;p&gt;What I'm trying to do is a C2C service that allows you to verify a user's identity when transferring sales to their account.&lt;/p&gt;

&lt;p&gt;I need to verify the identity of the user.&lt;/p&gt;

&lt;p&gt;We need the address, the real name, the driver's license and so on.&lt;/p&gt;

&lt;p&gt;In this article, we'll show you how to create an image of your driver's license.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an image
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://stripe.com/docs/api/files/create"&gt;Create a file&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const file = await stripe.files.create({
  purpose: 'dispute_evidence',
  file: {
    data: fp,
    name: 'file.jpg',
    type: 'application/octet-stream',
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, we need to send an image file to the server, so we create an image like the one above.&lt;/p&gt;

&lt;p&gt;It's like sending an image file, such as a driver's license, to an api, and then using the returned id, hitting another api to request identity authentication.&lt;/p&gt;

&lt;p&gt;If you hit the api as above, the id will be returned in the response, so use this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
{
  "id": "file_19yVPOfwefwefwefwefweO",
  "object": "file",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will use the id, so please save it in a variable somewhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  Register an identity.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://stripe.com/docs/api/accounts/update#update_account-individual-verification-document"&gt;Update an account&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the main topic of this article, so here's the actual code I wrote.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function UpdateAccounts(
  stripe_user_id,
  HEAD_ID_STRIPE_IMG, 
  BACK_ID_STRIPE_IMG
) {
  try {
    const account = await stripe.accounts.update(
      stripe_id_get_edit_connect_user,
      {
        individual: {
          verification:{document:{front: HEAD_ID_STRIPE_IMG, back: BACK_ID_STRIPE_IMG } }, 
        },
      },
    );
    console.log("アカウント")
    console.log(account)
  } catch (err) { 
    console.log("エラー");
    console.log(err);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Call the above function.&lt;/p&gt;

&lt;p&gt;Pass the id of the image file you've just created and the Stripe Connect user's account id as arguments.&lt;/p&gt;

&lt;p&gt;We won't be discussing Stripe Connect user accounts in this article.&lt;/p&gt;

&lt;p&gt;So, since this is an individual transaction, we'll pass in the id of the image as a string, as described in the individual section.&lt;/p&gt;

&lt;p&gt;By the way, this object can also contain an address and a name.&lt;/p&gt;

&lt;p&gt;You can find out more about these parameters in the official documentation.&lt;/p&gt;

&lt;p&gt;If you hit api in this state, there are only optional parameters in the api definition, so if the object is correct, the api should pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check with Stripe
&lt;/h2&gt;

&lt;p&gt;Now, let's check it out on the Stripe dashboard.&lt;/p&gt;

&lt;p&gt;As you can see in the image below, if the dentity document and identity document back are provided, then&lt;/p&gt;

&lt;p&gt;I think that the id of the image is correctly sent to the Stripe api.&lt;/p&gt;

&lt;p&gt;After that, you can wait for a while to see if your personal information is correctly authenticated or not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7V0v0ggy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/06/stripe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7V0v0ggy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/06/stripe.png" alt="stripe.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--&lt;/p&gt;

&lt;p&gt;&lt;a href="https://off.tokyo/blog/stripe-connect-img-add/"&gt;web media for tech lovers | off.tokyo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
    </item>
    <item>
      <title>When using WordPress on Amazon Lightsail, you should be careful about server corruption.</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Sat, 05 Jun 2021 12:46:29 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/when-using-wordpress-on-amazon-lightsail-you-should-be-careful-about-server-corruption-4ap</link>
      <guid>https://dev.to/off_tokyo_/when-using-wordpress-on-amazon-lightsail-you-should-be-careful-about-server-corruption-4ap</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Zq4gCzA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/px79dtigaqy75db4z5ll.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Zq4gCzA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/px79dtigaqy75db4z5ll.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://off.tokyo/blog/when-using-wordpress-on-amazon-lightsail-you-should-be-careful-about-server-corruption/"&gt;off.tokyo, the web media for high-tech lovers&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Amazon Lightsai has the ability to get WordPress up and running in an instant for about $3.5/month.&lt;/p&gt;

&lt;p&gt;There are no cumbersome contracts, no admin screens, and no contracts because you can turn off the instance as soon as it is no longer needed.&lt;/p&gt;

&lt;p&gt;It's very convenient and cheap, and I've used it quite a bit to set up multiple WordPress media.&lt;/p&gt;

&lt;p&gt;I've been using Amazon Lightsail for a long time now, but I'm thinking that running WordPress on Amazon Lightsail is a bad idea if you're not careful about the risk of the server breaking.&lt;/p&gt;

&lt;p&gt;I've been using Amazon Lightsail for a while now, and I've found it to be a great solution for my needs.&lt;/p&gt;

&lt;p&gt;I'm not sure if this is a good idea, but I'm sure it's a good idea.&lt;/p&gt;

&lt;p&gt;If you keep rebooting the instance over and over again, it will finally break and stop running.&lt;/p&gt;

&lt;p&gt;Then you can't even connect to SSH, and you're out of luck.&lt;/p&gt;

&lt;p&gt;I've only used Lollipop and X server so far, so I don't know much about other servers, but&lt;/p&gt;

&lt;p&gt;I've only used Lollipop and X server so far, and I don't know much about the other servers, but they have their advantages and disadvantages: Lollipop is cheap but heavy, X server is high performance but expensive.&lt;/p&gt;

&lt;p&gt;But since both servers did not have the disadvantage of dying and breaking and losing data, I underestimated the risk of such server breakage.&lt;/p&gt;

&lt;p&gt;I've ruined one site in the past because of it.&lt;/p&gt;

&lt;p&gt;After all, mazon lightsail is cheap, light, and easy to set up, and I'm so used to it that I can't be bothered to go with another service.&lt;/p&gt;

&lt;p&gt;I think I'll continue to use it in the future if it doesn't break too much in normal use (I don't know), but&lt;/p&gt;

&lt;p&gt;I'm not sure if I'll continue to use it in the future if it doesn't break too much, but I'm sure I will.&lt;/p&gt;

&lt;p&gt;If your server breaks and you can't get your instance up, it's over.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>aws</category>
    </item>
    <item>
      <title>How to receive images with the node.js API | fetch , React</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Tue, 01 Jun 2021 08:18:41 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/how-to-receive-images-with-the-node-js-api-fetch-react-3o2f</link>
      <guid>https://dev.to/off_tokyo_/how-to-receive-images-with-the-node-js-api-fetch-react-3o2f</guid>
      <description>&lt;p&gt;&lt;a href="https://off.tokyo/blog/node-api-img/"&gt;How to receive images with the node.js API | fetch , React - off.tokyo, the web site for high-tech enthusiasts&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  what i did
&lt;/h2&gt;

&lt;p&gt;The front side is built with React, and the form data is sent to the api by post using JavaScript fetch.&lt;/p&gt;

&lt;p&gt;Then, the api receives the form data and saves the data to the server.&lt;/p&gt;

&lt;p&gt;To edit the user's information, imagine that the user has to register his name and driver's license (back and front) with the service, and look at the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  node.js console.log
&lt;/h2&gt;

&lt;p&gt;In the following log, the form data created on the front side is received by post to get the data contained in the request.&lt;/p&gt;

&lt;p&gt;At first, I couldn't get the image in the body of the request, so I looked at the log of various requests, and found that the files contained image data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use_info&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use_info&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;img_head&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;img_head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;img_backkうううううう&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;img_back&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Front-side implementation fetch
&lt;/h2&gt;

&lt;p&gt;This is the code to post the user's name and image to the api on the front side.&lt;/p&gt;

&lt;p&gt;The user data and image data are added by using FormDate and appending to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;FormData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use_info&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Formdata&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;img_head&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Formdata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fileBack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;img_back&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Formdata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fileBack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;API_URL&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/edit_connect_user`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Server-side logs
&lt;/h2&gt;

&lt;p&gt;The following code is the log of the form data thrown from the front side by post.&lt;/p&gt;

&lt;p&gt;I think it contains the user's name and image data like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;use_info&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Pamyu Pamyu &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Kyary&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;userid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fekw020&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;img_head&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;img_head.png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9808&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;7bit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;tempFilePath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;truncated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;mimetype&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;image/png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;md5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c28358700f3c94f841c7f7fad50596da&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;mv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;mv&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;img_backk&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;img_backk.png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9808&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;7bit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;tempFilePath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;truncated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;mimetype&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;image/png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;md5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c28358700f3c94f841c7f7fad50596da&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nx"&gt;mv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;mv&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://off.tokyo/blog/node-api-img/"&gt;How to receive images with the node.js API | fetch , React - off.tokyo, the web site for high-tech enthusiasts&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>What is logical deletion and physical deletion?</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Mon, 17 May 2021 07:47:57 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/what-is-logical-deletion-and-physical-deletion-4916</link>
      <guid>https://dev.to/off_tokyo_/what-is-logical-deletion-and-physical-deletion-4916</guid>
      <description>&lt;p&gt;&lt;a href="https://off.tokyo/blog/what-is-logical-deletion-and-physical-deletion/"&gt;What is logical deletion and physical deletion? | off.tokyo&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;What is logical deletion?&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Logical deletion is the process of not actually deleting the data,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;but setting a column called "flag" to make it appear as if the data has been deleted to the user.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;For example, if you have a tweets table&lt;/p&gt;

&lt;p&gt;For example, if you have a tweets table, you can add a boolean column called deleted_flag to the table.&lt;/p&gt;

&lt;p&gt;In this state, the default value of the deleted_flag column is null.&lt;/p&gt;

&lt;p&gt;In this way, when a user presses the delete button of a tweet,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;the deleted_flag will be set to 1, and the tweet will be treated as deleted.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Physical Deletion&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;A physical deletion is an actual deletion in SQL,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;and is also deleted from the database.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Therefore, you can't restore or refer to the deleted data.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Advantages of Logical Deletion&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;As mentioned in the previous example,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;it only acts as if the data has been deleted, so it is possible to restore the data immediately.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Another advantage of logical deletion is that it is faster than physical deletion.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Disadvantages of logical deletion&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;You don't want to create NUll data in the database.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;(I think this can be solved somehow, though.)&lt;/p&gt;

&lt;p&gt;It is necessary to add a flag condition when&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;performing a narrowed search with a where clause.&lt;/p&gt;

</description>
      <category>database</category>
    </item>
    <item>
      <title>About redux-saga/effects put, call, take, select</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Sun, 16 May 2021 00:52:59 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/about-redux-saga-effects-put-call-take-select-dcn</link>
      <guid>https://dev.to/off_tokyo_/about-redux-saga-effects-put-call-take-select-dcn</guid>
      <description>&lt;p&gt;This time I used call, fork, put, take, and select.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;call: Wait for the promise to finish. The argument should be a function that returns a promise.&lt;/li&gt;
    &lt;li&gt;fork: Start another task. The argument can be an asynchronous function starting with *function*.&lt;/li&gt;
    &lt;li&gt;put: Dispatch an action.&lt;/li&gt;
    &lt;li&gt;take: wait for an action, an event to occur, and take as argument a string that is not a function of the action, but an action.type.&lt;/li&gt;
    &lt;li&gt;select: select data from a state, taking a function that takes a state as an argument.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When importing, use&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
import { call, fork, put, take, select } from 'redux-saga/effects'.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Write something like&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Here is a sample code&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;

function* callSample(){
    const { result, err } = yield call(getData) 
    if(result){
        console.log(result)
    } else {
        console.error(err)
    }
}

const getData = () =&amp;gt; {
    return axios.get('./get')
        .then( res =&amp;gt; {
            const result = res
            return {result} 
        })
        .catch( err =&amp;gt; {
            return {err}
        })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you give an argument to a function that returns a promise in call, it looks like this&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
function* callSample2(){
    const data = {
      name: 'hoge',
      password:'huga'
    }
    const {responce, err} = yield call(postData(data))
}
const postData = (data) =&amp;gt; {
    return axios('./post')
        .then( () =&amp;gt; { /*something*/ }
        .catch( () =&amp;gt; { /*something*/ }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The fork is a branch of the root task, and the process is written.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
//fork sample
export default function* rootSaga(){
    yield fork(forkSample)
}
function* forkSample(){
   //processing
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Put is used to dispatch actions according to the results of other asynchronous processes.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
//put sample
function* putSample(){
    const { result, err } = yield call(getData) 
    if(result){
        yield put(get(result))
    } else {
        console.log(err)
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Take will be executed when dispatched from elsewhere.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;

function* takeSample(){
    while(true) {
        const action = yield take("ADD")
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;

function* selectSample() {
        const state = yield select(getState)
    }
}


const getState = (state) =&amp;gt; ( state )
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

</description>
      <category>redux</category>
      <category>react</category>
    </item>
    <item>
      <title>About CSS Grid Layout</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Sun, 09 May 2021 00:57:36 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/about-css-grid-layout-1p2i</link>
      <guid>https://dev.to/off_tokyo_/about-css-grid-layout-1p2i</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B59kaZhN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/05/css.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B59kaZhN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/05/css.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The 2017 macOS and iOS updates include a version of Safari that implements the CSS Grid Layout Module,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;which is finally available in all modern browsers.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;It's a very flexible and intuitive way to represent grids. In today's post, I'd like to study this again.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;(Note that this article is based on a Japanese article and only the necessary points have been translated.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://qiita.com/morishitter/items/738488290451555d913c"&gt;https://qiita.com/morishitter/items/738488290451555d913c&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Defining the Grid&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;When you want an element to be laid out in a grid, you need to specify display: grid or display: inline-grid for its parent element.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This parent element is called the grid container, and the child elements to be grid-layout are called grid items.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The grid container can have the properties grid-template-column and grid-template-row.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Each of these specifies the size of the grid in columns and rows, in terms of the number of columns and rows.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Example: A grid with 3 rows and 5 columns&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;.container {
  grid-template-columns: 40px 50px auto 50px 40px;
  grid-template-rows: 25% 100px auto;
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Properties that can be specified for the grid container&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;grid-gap&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;To be precise, grid-gap is a short-hand for grid-column-gap and grid-row-gap.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;It specifies the margin between columns and rows between grid items.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Example: 10px margin for columns, 15px margin for rows&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;.container {
  grid-gap: 10px 15px;
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;justify-items, align-items, justify-content, align-content&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;These are the same properties used in Flexbox layouts. They are not part of the Flexbox specification,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;but are part of the Box Alignment Module, which can also be used for grid containers.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;These properties are used to align grid items, and are not new to CSS Grid, so their usage is omitted.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;grid-template-areas&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This property allows you to give a name to a grid item. You don't need to learn how to use it.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;.container {
  grid-template-columns: 50px 50px 50px 50px;
  grid-template-rows: auto;
  grid-template-areas: 
    "header header header header"
    "main main . sidebar"
    "footer footer footer footer";
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The way it is written is very weird&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;. is specified for an empty grid.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Properties that can be specified for grid items&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This section describes the properties that can be specified for grid items,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;which are children of the grid container. Note that float, clear, and vertical-align do not apply to grid items.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;grid-column, grid-row&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;grid-template-column and grid-template-row define the grid, and it is these properties that determine which elements are placed where.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;To be precise, grid-column is the shorthand for grid-column-start and grid-column-end, and grid-row is the shorthand for grid-row-start and grid-row-end.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;There is also grid-area, which is a shorthand for grid-column and grid-row, but it's easier to just use grid-column and grid-row.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;These properties specify gridlines (sometimes called Line-based Placement).&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u8Kt06G---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/05/css2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u8Kt06G---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/05/css2.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;grid-column specifies the start and end lines of a column, grid-row specifies the start and end lines of a row.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;.container {
  display: grid;
  grid-template-columns: 100px 100px 100px;
  grid-gap: 10px;
}

.item-a {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.item-b {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;justify-self, align-self&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This was also present in the Flexbox layout. This property aligns the specified grid items.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;An aside&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;"Grids" have always been possible using &amp;lt;table&amp;gt; tags, floats, display: inline-block, display: table, Flexbox, etc. However, with the creation of the CSS Grid specification, it is now possible to create grids without using a preprocessor mixin or a grid framework. However, there is now a specification for grids called CSS Grid, which allows you to create grids without using a preprocessor mixin or a grid framework. In my opinion, the biggest benefit of using CSS Grid is that you can write display: grid to represent a grid and put your design intent into your code. Also, it's easier to remember CSS Grid properties if you are aware of which properties are for the grid container and which are for the grid items, as in the case of Flexbox.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Incidentally, there is also a value called display: subgrid, which is used to turn a grid item into a grid container and its children into a grid layout, but this has been moved to the Level 2 specification and is currently not implemented outside of Firefox. In the future, it is better to use CSS Grid to represent grids, and Flexbox for layout within components.&lt;/p&gt;

&lt;h3&gt;
  
  
  source
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://off.tokyo/blog/about-css-grid-layout/"&gt;https://off.tokyo/blog/about-css-grid-layout/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>grid</category>
    </item>
    <item>
      <title>Writing Iterator and Generator using JavaScript</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Sat, 01 May 2021 04:29:33 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/writing-iterator-and-generator-using-javascript-53m5</link>
      <guid>https://dev.to/off_tokyo_/writing-iterator-and-generator-using-javascript-53m5</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7lX2DD9N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/javascript.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7lX2DD9N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/javascript.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;source : &lt;a href="https://off.tokyo/blog/writing-iterator-and-generator-using-javascript/"&gt;Writing Iterator and Generator using JavaScript | off.tokyo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Iteration is the foundation of programming. The degree to which a programming language helps you iterate makes a big difference in your programming comfort.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;JavaScript has been a lagging language when it comes to iteration. However, with the introduction of Iterator and Generator, this is about to change.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Iterator&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Itreable and Iterator&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;In JavaScript, an object that can be iterated over is called an iterable, and typical examples of iterables are Arrays and Maps. A typical example of an Iterable is an Array or Map, which is iterable because it has multiple values.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;An Iterable object has an Iterator, which can be obtained with Iterable&lt;a href=""&gt;Symbol.iterator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;const array = [1, 2, 3];
const iterator = array[Symbol.iterator]();&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Iterator has only one method, next(), which can be used to retrieve the next value in an Iterable.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;const array = [1, 2, 3];
const iterator = array[Symbol.iterator]();

console.log(iterator.next().value); // 1
console.log(iterator.next().value); // 2
console.log(iterator.next().value); // 3&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The value obtained by next() is an object that is {value: the next value, done: whether it has finished or not}.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;By checking the value of value, we can get the value of Iterable.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;By checking the value of value, we can get the value of the Iterable, and by checking the value of done, we can get the value of the bool to see if the iteration has finished or not.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;In other words, the above code can be rewritten using a loop as follows&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;const array = [1, 2, 3];
const iterator = array[Symbol.iterator]();

let next = iterator.next();
while(!next.done) {
  console.log(next.value); // 1 2 3
  next = iterator.next();
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Iterator is a smart way to write iterations.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;However, this is still cumbersome. Therefore, javaScript provides a simpler way to write Iterator iteration.&lt;/p&gt;

&lt;h3&gt;The for-of statement&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The for-of statement is the easiest way to handle an Iterable.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Rather than explaining it in words, it will be easier to understand if you look at the code first.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;const array = [1, 2, 3];

for(const val of array) {
  console.log(val); // 1 2 3
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Creating your own Iterators and Iterables&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;It is also possible to create your own Iterators and Iterables.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Creating an Iterator is as simple as implementing a next() method that returns {value, done}.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Iterable is also a simple matter of implementing &lt;a href=""&gt;Symbol.iterator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;For example, let's consider implementing the range() function.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The functions to create an Iterator and an Iterable look like the following&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;function createRangeIterator(end) {
  let currentValue = 0;
  const iterator = new Object();

  iterator.next = () =&amp;gt; {
    const value = currentValue++;
    const done = currentValue &amp;gt; end;
    const result = done ? {done: done} : {value: value, done: done};
    return result;
  };
  
  return iterator;
}

function range(end) {
  const iterable = new Object();
  iterable[Symbol.iterator] = () =&amp;gt;  createRangeIterator(end);
  
  return iterable;
}

for(const val of range(3)) {
  console.log(val); // 0 1 2
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Since the Iterator mechanism is simple, it is easy to create your own.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Generator&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Generator function and yield return&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Even though the Iterator mechanism itself is simple, the actual implementation is quite lengthy. Of course, there are excellent programmers who can read and write this code easily, but it is difficult for most people to do so.&lt;/p&gt;

&lt;p&gt;The Generator provides a very easy way to work with Iterators and Iterables, allowing you to automatically iterate over them with simple code.&lt;/p&gt;

&lt;p&gt;To use the Generator, use function* instead of function, and yield instead of return. To use Generator, use function* instead of function,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;and yield instead of return. This is all you need to complete the Generator. Here, the function defined by function* is called the Generator function.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;function* generator() {
  yield 1;
  yield 2;
  yield 3;
}

for(const val of generator()) {
  console.log(val); // 1 2 3
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The Generator function returns a Generator object.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The Generator object is an Iterable and an Iterator object.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The generator object is both an Iterator and an Iterator object, and can be used as an Iterator, such as generator.next().value, or as an Iterable, such as using for-of to retrieve a value.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;When next() is called, the Generator function will stop and return the yielded value each time it is yielded.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;When next() is called again, it resumes function execution and proceeds to the next yield.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The Generator behaves like an Iterator by repeating this process.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;yield* to yield an Iterable&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;You can also use yield* instead of yield to automatically yield the contents of an Iterable one by one.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;function* generator() {
  yield* [1, 2, 3];
}

for(const val of generator()) {
  console.log(val); // 1 2 3
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Saving the Context&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;yield and yield* preserve the context of the function. This means that the values of variables in the function will be preserved. As a concrete example, you can write a generator like the following&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;function* generator() {
  for(let i=0; i&amp;lt; 3; i++) {
    yield i;
  }
}

for(const val of generator()) {
  console.log(val); // 0 1 2
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;By using this, for example, the previous range function can be easily written as follows&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;function* range(end) {
  for(let i=0; i &amp;lt; end; i++) {
    yield i;
  }
}

for(const val of range(3)) {
  console.log(val); // 0 1 2
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;I was able to write it much more easily.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Iterable objects are Iterable&lt;/li&gt;
    &lt;li&gt;Iterable objects have an Iterator.&lt;/li&gt;
    &lt;li&gt;Iterable can be easily iterated by using for-of statement&lt;/li&gt;
    &lt;li&gt;Iterator and Iterable can be created by oneself.&lt;/li&gt;
    &lt;li&gt;Iterables can be easily created using the Generator.&lt;/li&gt;
    &lt;li&gt;Generator is both an Iterable and an Iterator&lt;/li&gt;
    &lt;li&gt;Generator is both an Iterable and an Iterator ・Yield can be used to return the next value&lt;/li&gt;
    &lt;li&gt;The generator is an Iterable and an Iterator.&lt;/li&gt;
    &lt;li&gt;The context is preserved even if the function is temporarily exited by yield.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;＊This article is a summary of the Japanese article with only the main points explained in an easy-to-understand manner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sbfl.net/blog/2016/08/17/javascript-iterator-generator/"&gt;https://sbfl.net/blog/2016/08/17/javascript-iterator-generator/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding JavaScript iterators</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Fri, 30 Apr 2021 04:24:09 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/understanding-javascript-iterators-4egk</link>
      <guid>https://dev.to/off_tokyo_/understanding-javascript-iterators-4egk</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7lX2DD9N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/javascript.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7lX2DD9N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/javascript.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://off.tokyo/blog/understanding-javascript-iterators/"&gt;source : Understanding JavaScript iterators&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Iterators and generators are a big feature of ECMAScript 6 (released in June 2015 and still relatively new to JavaScript).&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;And It's a huge, complex system, and complicated.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;So In this article, I'd like to explain iterators in a way that you can understand them step by step.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;What is an Iterator Result?&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;An iterator is an object from which iterator results can be retrieved in order.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Specifically, an object that satisfies the following two points is called an iterator.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;It must have a .next() method&lt;/li&gt;
    &lt;li&gt;When .next() is executed, it returns the iterator result.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;In other words, in the following code, iterator is an iterator.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;var iterator = {}; 
iterator.next = function(){
    var iteratorResult = { value: 42, done: false };
    return iteratorResult;
};&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Here, in the code above, we see an iterator result called iteratorResult.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;As you can see, the iterator result is an object and has the .value and .done properties.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The role of each property is as follows&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;The .value property is the value (item) retrieved from the iterator.&lt;/li&gt;
    &lt;li&gt;The .done property is a boolean value indicating whether or not the value has been sequentially extracted from the iterator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;What is Iterable?&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;An iterable is an object that has an iterator.&lt;/p&gt;

&lt;p&gt;To be more specific, an object is said to be iterable if it satisfies the following&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;When the [Symbol.iterator]() method is executed, it should return an iterator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;In other words, in the following code, obj is iterable.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var iterator = {}; 
iterator.next = function(){
    var iteratorResult = { value: 42, done: false }; // イテレータリザルト
    return iteratorResult;
};

var obj = {}; 
obj[Symbol.iterator] = function(){
    return iterator;
};&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;An object that is iterable is also called an iterable object.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This relationship is shown in the figure below.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;(Sorry for the Japanese, please just read and understand the English part.)&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uJwBaPQ2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uJwBaPQ2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/i.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dRtsuji0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/i2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dRtsuji0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/i2.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Create an iterable object.&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;As a simple example, let's create an iterable object with an iterator that can fetch the numbers 1 through 10 in order.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var obj = {}; // iterable object
obj[Symbol.iterator] = function(){
    var iterator = {}; // iterator
    var count = 1;
    iterator.next = function(){
        var iteratorResult = (count &amp;lt;= 10)
            ? { value: count++, done: false }
            : { value: undefined, done: true };
        return iteratorResult; // iterator result
    };
    return iterator;
};&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The current value is stored in the variable count, and each time .next() is executed, the value is counted up and returned in .value.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;When count exceeds 10, we set .done to true to indicate that we have finished retrieving the values in order.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Now we have an iterable object with an iterator that can fetch the numbers 1 to 10 in order.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Extract values from iterators in order&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Let's extract the values from the iterator we just created in order and output them to the console.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;We will use the property that .next() can be used to retrieve the iterator result.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var obj = {}; // iterable object
obj[Symbol.iterator] = function(){
    var iterator = {}; // iterator
    var count = 1;
    iterator.next = function(){
        var iteratorResult = (count &amp;lt;= 10)
            ? { value: count++, done: false }
            : { value: undefined, done: true };
        return iteratorResult; // iterator result
    };
    return iterator;
};

var iterator = obj[Symbol.iterator](); // get the iterator from an iterable object
var iteratorResult;
while(true){
    iteratorResult = iterator.next(); // retrieve the values in order
    if(iteratorResult.done) break; // break when finished fetching
    console.log(iteratorResult.value); // output the value to the console
}
/* 1
  1
  2
  3
  ...
  10
*/ ...
&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Now, we can extract the values from the iterator in order.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;However, this is code that can be written in ECMAScript 5, and the way it is written is unnecessarily complicated, so You migthj don't see much benefit in it.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The reason why iterators are so useful is that you can use the for(v of iterable) syntax to get the values more easily.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Easier to extract values from iterators&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;A convenient syntax provided for extracting values from an iterator is for(v of iterable).&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;var obj = {}; // iterable object
obj[Symbol.iterator] = function(){
    var iterator = {}; // iterator
    var count = 1;
    iterator.next = function(){
        var iteratorResult = (count &amp;lt;= 10)
            ? { value: count++, done: false }
            : { value: undefined, done: true };
        return iteratorResult; // iterator result
    };
    return iterator;
};

for(var v of obj) console.log(v);
/*
  1
  2
  3
  ...
  10
*/ ...
&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This syntax, for(v of iterable), executes the following steps in order.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;blockquote&gt;First, execute iterator = iterable[Symbol.iterator]() to get the iterator.

↓

Next, execute iteratorResult = iterator.next() to retrieve the iterator result.

↓

If iteratorResult.done == true, iteratorResult.done has been retrieved and quits. Otherwise, go to next.

↓

Assign v = iteratorResult.value and execute the statement (console.log(v)).

↓

Next, execute iteratorResult = iterator.next() to retrieve the iterator result.&lt;/blockquote&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Iterable objects prepared from official&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;By using for(v of iterable), It was able to write much smarter code.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;However, the part that defines the iterable object is very long.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;In fact, there is an iterable object that is already provided in JavaScript,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;without having to define it yourself.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Related to Arrays&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;First, the array itself is an iterable object.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;var obj = ["A", "B", "C"]; // イテラブルなオブジェクト
for(var v of obj) console.log(v);
/*
  "A"
  "B"
  "C"
*/&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;To check, let's see if the array is an iterable object with the properties we have raised so far.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var obj = ["A", "B", "C"]; // iterable object
var iterator = obj[Symbol.iterator]();
console.log(typeof iterator); // "object". We are indeed getting an iterator.
console.log(iterator.next()); // { value: "A", done: false }&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Arrays also have a .keys() method that allows you to get an iterator to retrieve the array keys in order.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var obj = ["A", "B", "C"]; // iterable object
for(var v of obj.keys()) console.log(v);
/*
  0
  1
  2
/* 0 1 2&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Arrays also have the .entries() method, which allows you to retrieve an iterator that fetches an array of keys and values in sequence.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var obj = ["A", "B", "C"]; // iterable object
for(var v of obj.entries()) console.log(v);
/*
  [0, "A"]
  [1, "B"]
  [2, "C"]
*/ [0, "A"] [1, "B"] [2, "C"].&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;String&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;A string object is also an iterable object.&lt;/p&gt;

&lt;p&gt;It can be used to extract characters one by one from the beginning of a string.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var str = "あいう";
for(var v of str) console.log(v);
/*
  "あ"
  "い"
  "う"
*/&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;To check, let's see if the string is also an iterable object with the same properties as we have mentioned so far.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var str = "あいう";
var iterator = str[Symbol.iterator]();
console.log(typeof iterator); // "object"
console.log(iterator.next()); // { value: "あ", done: false }&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Iterators&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The iterators provided in JavaScript are actually iterable objects in their own right.&lt;/p&gt;

&lt;p&gt;Therefore, executing the &lt;a href=""&gt;Symbol.iterator&lt;/a&gt; method will return itself.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var obj = ["A", "B", "C"]; // イテラブルなオブジェクト
var iterator = obj[Symbol.iterator](); // イテレータを取得する
for(var v of iterator) console.log(v); // for-of にイテレータを渡す
/*
  "A"
  "B"
  "C"
*/

console.log(iterator === iterator[Symbol.iterator]()); // true&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Generators&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Generators, which are created by generator functions, are both iterable objects and iterators.&lt;/p&gt;

&lt;p&gt;Generators are also a very rich mechanism, which will be explained in another article.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;function* gfn(n){
    while(n &amp;lt; 100){
        yield n;
        n *= 2;
    }
}
var gen = gfn(3);
for(var v of gen) console.log(v);
/*
  3
  6
  12
  24
  48
  96
*/&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Other stuff&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;There are also various other iterable objects.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Arguments&lt;/p&gt;


&lt;pre&gt;// Firefox 40 dose not work
function func(){
    for(var v of arguments) console.log(v);
}
func(42, "あ", true);
/*
  42
  "あ"
  true
*/&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;TypedArray&lt;/p&gt;


&lt;pre&gt;var view = new Uint8Array([0, 1, -1]);
for(var v of view) console.log(v);
/*
  0
  1
  255
*/&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Map&lt;/p&gt;


&lt;pre&gt;var map = new Map([[0, "Zero"], [{}, "Object"], [[], "Array"]]);
for(var v of map) console.log(v);
/*
  [0, "Zero"]
  [{}, "Object"]
  [[], "Array"]
*/&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Set&lt;/p&gt;


&lt;pre&gt;var set = new Set([0, {}, []]);
for(var v of set) console.log(v);
/*
  0
  {}
  []
*/&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;There's more! How to use iterators&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;We used an iterator with the syntax for(v of iterable).&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Actually, there are many other ways to use iterators.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Array&lt;/h3&gt;

&lt;p&gt;[... .iterable] syntax.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;From iterable, you can create an array in which the values are extracted in order and the number of elements are placed in the corresponding part.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var ary = [0, "A", false];
var str = "あいう";
var connectedAry = [...ary, ...str];
console.log(connectedAry);
/*
  [0, "A", false, "あ", "い", "う"]
*/&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;You can also use the syntax Array.from(iterable) to do the same thing.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var str = "あいう";
var ary = Array.from(str);
console.log(ary); // ["あ", "い", "う"]&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Argument passing&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The syntax is func(. .iterable) syntax.&lt;/p&gt;

&lt;p&gt;The values are taken out of iterable in order, and the function is executed so that the number of arguments are placed in the corresponding part.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;var nums = [112, 105, 121, 111];
console.log( Math.max(...nums) ); // 121
console.log( String.fromCharCode(...nums) ); // "piyo"
&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Split Assignment&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The syntax is [a, b, c] = iterable.&lt;/p&gt;

&lt;p&gt;The values are taken out of iterable in order and assigned to the variables on the left side in order.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;var [a, b, c] = "ひよこ";
console.log(c+b+a); // "こよひ"&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Map, Set, WeakMap, WeakSet&lt;/h3&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The syntax is new Map(iterable), new Set(iterable), new WeakMap(iterable), new WeakSet(iterable).&lt;br&gt;
Each iterable takes a value in turn, and the keys and values can be specified.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;var set = new Set("あいうあお");
console.log(set); // Set {"あ", "い", "う", "お"}

var map = new Map(["A", "B", "C"].entries());
console.log(map); // Map {0 =&amp;gt; "A", 1 =&amp;gt; "B", 2 =&amp;gt; "C"}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Practical sample&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This is an application of the previous content.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Output array elements one by one to the console.&lt;/h3&gt;

&lt;pre&gt;var ary = [0, 5, 9, 2, 7];
for(var v of ary) console.log(v);
/*
  0
  5
  9
  2
  7
*/&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Copying an array&lt;/h3&gt;

&lt;pre&gt;var ary0 = [1, 2, 3];
var ary1 = [...ary0];
console.log(ary0.join() === ary1.join()); // true
console.log(ary0 === ary1); // false&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Assigning the first element of an array&lt;/h3&gt;

&lt;pre&gt;var ary = ["A", "B", "C"];
var [first] = ary;
console.log(first); // "A"&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Assign the first character of a string&lt;/h3&gt;

&lt;pre&gt;var str = "ABC";
var [first] = str;
console.log(first); // "A"&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Remove duplicate values from an array&lt;/h3&gt;

&lt;pre&gt;var ary = [0, 5, 9, 0, 2, 5];
var uniqueAry = [...new Set(ary)];
console.log(uniqueAry); // [ 0, 5, 9, 2 ]&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Pass variable length arguments to functions without using .apply()&lt;/h3&gt;

&lt;pre&gt;var nums = [112, 105, 121, 111];
console.log( Math.max(...nums) ); // 121
console.log( String.fromCharCode(...nums) ); // "piyo"&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt; Assign the matched and partially matched characters all at once.&lt;/h3&gt;

&lt;pre&gt;var [all, part] = "abcde".match(/ab(.)de/)
console.log(all, part); // "abcde", "c"&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;span&gt;＊This article is based on the Japanese article below and has been translated into English for easier understanding.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://qiita.com/kura07/items/cf168a7ea20e8c2554c6"&gt;https://qiita.com/kura07/items/cf168a7ea20e8c2554c6&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Javascript window object</title>
      <dc:creator>off.tokyo</dc:creator>
      <pubDate>Sun, 25 Apr 2021 05:41:23 +0000</pubDate>
      <link>https://dev.to/off_tokyo_/understanding-javascript-window-object-310</link>
      <guid>https://dev.to/off_tokyo_/understanding-javascript-window-object-310</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7lX2DD9N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/javascript.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7lX2DD9N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/javascript.jpg" alt="" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;What is the window object?&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Window&lt;/code&gt; is the main JavaScript object root, aka the &lt;code&gt;global object&lt;/code&gt; in a browser,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Also can be treated as the root of the document object model.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;You can access it as &lt;code&gt;window&lt;/code&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/9895202/what-is-the-difference-between-window-screen-and-document-in-javascript"&gt;What is the difference between window, screen, and document in Javascript?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;In other words, in simple terms, you can use these to control your browser.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Let's actually use the browser's console to control the browser in various ways.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;window.alert('hello,world');
&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Omt1BLh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/window.alerthelloworld-scaled.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Omt1BLh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/window.alerthelloworld-scaled.jpg" alt="" width="771" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The functions and objects prepared in advance in JavaScript are all properties of the window object.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;window.document, which is used to retrieve and manipulate HTML data,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;and window.location, which stores information such as URLs, are all properties of the window object.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This is because information such as HTML and URLs is information that the browser window has.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;// Move to Your_Name Wiki
window.location.href('https://en.wikipedia.org/wiki/Your_Name');&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;Omitting the window object&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The window object is handled in a special way in JavaScript,&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;and the window can be omitted when accessing the window object's properties.&lt;/p&gt;

&lt;p&gt;In other words, window.alert can be written simply as alert.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;


&lt;pre&gt;alert('hello,world');
&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This is a special rule only for the window object, and it is a rule like this.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Here are the main objects in the properties of the "window" object.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;document
The document object is mainly used to retrieve and manipulate HTML documents.&lt;/li&gt;
    &lt;li&gt;location ---- URL information
An object to get or change the URL information of the displayed page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Example 1- Getting the URL&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;var url = location.href;
document.write(url); //=&amp;gt; Write out the URL of the currently displayed page&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ihC2n10A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/var-url-location.href-document.writeurl-Write-out-the-URL-of-the-currently-displayed-page-scaled.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ihC2n10A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/var-url-location.href-document.writeurl-Write-out-the-URL-of-the-currently-displayed-page-scaled.jpg" alt="" width="2560" height="1091"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Example 2- Change the URL to the assigned value&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;location.href = "http://test.jp"&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;history --- history management
The history object manages the history. The main properties are summarized below.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;length : the number of pages in the history 5&lt;/li&gt;
    &lt;li&gt;back : Go back to the previous page (function without return value)&lt;/li&gt;
    &lt;li&gt;forward : Go to the next page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, the usage of "history.back" ↓&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre&gt;// go back to the previous page
history.back();&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;navigator --- Browser Metadata&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The navigator object is an object used to handle metadata about the browser type and version.&lt;br&gt;
The most commonly used one is "navigator.userAgent".&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Rw07Y4Lt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/document.writenavigator.userAgent.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rw07Y4Lt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://off.tokyo/wp-content/uploads/2021/04/document.writenavigator.userAgent.png" alt="" width="3460" height="1700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;That's how it is.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This article was adapted from this article in Japanese.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://qiita.com/tsukishimaao/items/39d22fd9178546d6cdeb"&gt;windowオブジェクト&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;source : &lt;a href="%5Bhttps://off.tokyo/blog/understanding-javascript-window-object/"&gt;Understanding Javascript window object | off.tokyo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
