<?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: Ernesto Herrera</title>
    <description>The latest articles on DEV Community by Ernesto Herrera (@ernerdo).</description>
    <link>https://dev.to/ernerdo</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%2F801443%2F79d9a13f-9fda-4b15-ad88-9dec79185ab4.jpeg</url>
      <title>DEV Community: Ernesto Herrera</title>
      <link>https://dev.to/ernerdo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ernerdo"/>
    <language>en</language>
    <item>
      <title>Laravel Best Naming Conventions for APIs</title>
      <dc:creator>Ernesto Herrera</dc:creator>
      <pubDate>Tue, 28 Feb 2023 03:30:32 +0000</pubDate>
      <link>https://dev.to/ernerdo/laravel-best-naming-conventions-for-apis-2d0c</link>
      <guid>https://dev.to/ernerdo/laravel-best-naming-conventions-for-apis-2d0c</guid>
      <description>&lt;p&gt;In Laravel 8, there are some conventions that are widely accepted for naming APIs. Following these conventions can make your code more maintainable and easier to understand for other developers. Here are some of the best naming conventions for APIs in Laravel 8:&lt;/p&gt;

&lt;h2&gt;
  
  
  Route Names
&lt;/h2&gt;

&lt;p&gt;For route names, it is recommended to use a verb followed by a noun. This approach is simple, yet effective, because it accurately describes what each route does. It also makes it easy to generate URLs for each route. For example, &lt;code&gt;GET /users&lt;/code&gt; would have a route name of &lt;code&gt;users.index&lt;/code&gt;. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GET /users&lt;/code&gt; =&amp;gt; &lt;code&gt;users.index&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GET /users/create&lt;/code&gt; =&amp;gt; &lt;code&gt;users.create&lt;/code&gt; it is used to show a form that allows to create a new user.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;POST /users&lt;/code&gt; =&amp;gt; &lt;code&gt;users.store&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GET /users/{id}&lt;/code&gt; =&amp;gt; &lt;code&gt;users.show&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GET /users/{id}/edit&lt;/code&gt; =&amp;gt; &lt;code&gt;users.edit&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PUT/PATCH /users/{id}&lt;/code&gt; =&amp;gt; &lt;code&gt;users.update&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DELETE /users/{id}&lt;/code&gt; =&amp;gt; &lt;code&gt;users.destroy&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is also a good practice to group related routes using route prefixes. This technique can help you organize your routes and make them easier to read. For example, you might group all of your user-related routes under a &lt;code&gt;/users&lt;/code&gt; prefix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Route::prefix('users')-&amp;gt;group(function () {
    Route::get('/', 'UsersController@index')-&amp;gt;name('users.index');
    Route::get('/create', 'UsersController@create')-&amp;gt;name('users.create');
    Route::post('/', 'UsersController@store')-&amp;gt;name('users.store');
    Route::get('/{id}', 'UsersController@show')-&amp;gt;name('users.show');
    Route::get('/{id}/edit', 'UsersController@edit')-&amp;gt;name('users.edit');
    Route::put('/{id}', 'UsersController@update')-&amp;gt;name('users.update');
    Route::delete('/{id}', 'UsersController@destroy')-&amp;gt;name('users.destroy');
});

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Controller Names
&lt;/h2&gt;

&lt;p&gt;For controller names, it is recommended to use a plural noun followed by the &lt;code&gt;Controller&lt;/code&gt; suffix. This approach is consistent with the idea of using plural nouns for resources, and it accurately describes what each controller does. For example, a controller for managing users would be named &lt;code&gt;UsersController&lt;/code&gt;. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;UsersController&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PostsController&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;CommentsController&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;TagsController&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;CategoriesController&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Model Names
&lt;/h2&gt;

&lt;p&gt;For model names, it is recommended to use a singular noun. This approach accurately reflects the fact that each model represents a single entity in your application. It also makes it easy to generate model instances. For example, a model for managing users would be named &lt;code&gt;User&lt;/code&gt;. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;User&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Post&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Comment&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Tag&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Category&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Resource Names
&lt;/h2&gt;

&lt;p&gt;For resource names, it is recommended to use a plural noun. This approach makes it easy to understand that each resource represents a collection of entities, rather than a single entity. It also makes it easy to generate URLs for each resource. For example, a resource for managing users would be named &lt;code&gt;Users&lt;/code&gt;. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Users&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Posts&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Comments&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Tags&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Categories&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Database Table Names
&lt;/h2&gt;

&lt;p&gt;For database table names, it is recommended to use a plural noun. This approach is consistent with the idea of using plural nouns for resources. It also makes it easy to understand that each table represents a collection of entities, rather than a single entity. For example, a table for managing users would be named &lt;code&gt;users&lt;/code&gt;. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;users&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;posts&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;comments&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tags&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;categories&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  API Versioning
&lt;/h2&gt;

&lt;p&gt;Versioning your API is important to ensure that changes do not break existing clients. There are various ways to version your API, but one popular method is to use version numbers in your URLs. For example, &lt;code&gt;/v1/users&lt;/code&gt; would be the URL for version 1 of the users API. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/v1/users&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/v2/users&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/v1/posts&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/v2/posts&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another approach to API versioning is to use custom HTTP headers. This approach can be useful when you do not want to modify your URLs. For example, you might use a custom &lt;code&gt;X-Api-Version&lt;/code&gt; header to specify the API version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /users HTTP/1.1
Host: example.com
X-Api-Version: 1

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  HTTP Response Codes
&lt;/h2&gt;

&lt;p&gt;HTTP response codes are an important part of any API. They provide information about the result of the request and help clients understand what happened. Here are some common HTTP response codes and what they mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;200 OK&lt;/code&gt; - The request succeeded.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;201 Created&lt;/code&gt; - The request succeeded and a new resource was created.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;204 No Content&lt;/code&gt; - The request succeeded, but there is no response body to return.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;400 Bad Request&lt;/code&gt; - The request was malformed or invalid.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;401 Unauthorized&lt;/code&gt; - The request requires authentication.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;403 Forbidden&lt;/code&gt; - The authenticated user does not have access to the requested resource.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;404 Not Found&lt;/code&gt; - The requested resource does not exist.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;422 Unprocessable Entity&lt;/code&gt; - The request was well-formed, but was unable to be followed due to semantic errors.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;500 Internal Server Error&lt;/code&gt; - A generic error occurred on the server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pagination
&lt;/h2&gt;

&lt;p&gt;If you are returning a large number of resources, it is important to paginate your results. Pagination allows clients to retrieve resources in smaller, more manageable chunks. Laravel provides built-in support for pagination, making it easy to implement in your APIs. Here are some examples of how to paginate your results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;GET /users?page=1&amp;amp;per_page=10&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GET /posts?page=2&amp;amp;per_page=5&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Authentication
&lt;/h2&gt;

&lt;p&gt;Authentication is an important part of any API. It allows you to restrict access to certain resources and ensure that only authorized clients can access your API. Laravel provides built-in support for various authentication mechanisms, such as API tokens and OAuth2. Here are some examples of how to use these mechanisms:&lt;/p&gt;

&lt;h3&gt;
  
  
  API Tokens
&lt;/h3&gt;

&lt;p&gt;API tokens are a simple way to authenticate clients. Each client is issued a unique token that they use to authenticate their requests. Laravel provides built-in support for API tokens, making it easy to implement in your APIs. Here are some examples of how to use API tokens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Generate a new token for the user
$token = $user-&amp;gt;createToken('token-name')-&amp;gt;plainTextToken;

// Authenticate a request using the token
$response = $client-&amp;gt;get('/api/user', [
    'headers' =&amp;gt; [
        'Authorization' =&amp;gt; 'Bearer ' . $token,
        'Accept' =&amp;gt; 'application/json',
    ],
]);

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  OAuth2
&lt;/h3&gt;

&lt;p&gt;OAuth2 is a more complex mechanism for authenticating clients. It involves a series of redirects and exchanges of tokens between the client and the server. Laravel provides built-in support for OAuth2, making it easy to implement in your APIs. Here are some examples of how to use OAuth2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Generate an authorization URL for the client
$url = $provider-&amp;gt;getAuthorizationUrl();

// Redirect the client to the authorization URL
return redirect($url);

// Handle the callback from the provider
$token = $provider-&amp;gt;getAccessToken('authorization_code', [
    'code' =&amp;gt; $request-&amp;gt;code,
]);

// Authenticate a request using the access token
$response = $client-&amp;gt;get('/api/user', [
    'headers' =&amp;gt; [
        'Authorization' =&amp;gt; 'Bearer ' . $token-&amp;gt;getToken(),
        'Accept' =&amp;gt; 'application/json',
    ],
]);

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Error Handling
&lt;/h2&gt;

&lt;p&gt;Error handling is an important part of any API. It allows you to provide meaningful error messages to clients when something goes wrong. Laravel provides built-in support for error handling, making it easy to implement in your APIs. Here are some examples of how to handle errors in your APIs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Throw an exception when a resource is not found
if (!$user) {
    throw new NotFoundHttpException('User not found.');
}

// Return a JSON response when a validation error occurs
if ($validator-&amp;gt;fails()) {
    return response()-&amp;gt;json([
        'message' =&amp;gt; 'The given data was invalid.',
        'errors' =&amp;gt; $validator-&amp;gt;errors(),
    ], 422);
}

// Return a JSON response when an unexpected error occurs
if ($exception instanceof Exception) {
    return response()-&amp;gt;json([
        'message' =&amp;gt; 'An unexpected error occurred.',
    ], 500);
}

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

&lt;/div&gt;



</description>
      <category>laravel</category>
      <category>conventions</category>
    </item>
    <item>
      <title>Ten Modern Layouts 🚀 [Part 3]</title>
      <dc:creator>Ernesto Herrera</dc:creator>
      <pubDate>Sat, 18 Feb 2023 02:38:02 +0000</pubDate>
      <link>https://dev.to/ernerdo/ten-modern-layouts-part-3-4id7</link>
      <guid>https://dev.to/ernerdo/ten-modern-layouts-part-3-4id7</guid>
      <description>&lt;p&gt;This is the third part and final of the "Ten Modern Layouts"&lt;br&gt;
&lt;a href="https://dev.to/ernerdo/ten-modern-layouts-part-1-a3m"&gt;If you aren't read the part 1, here you can read it&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://dev.to/ernerdo/ten-modern-layouts-part-2-3o6o"&gt;If you aren't read the part 2, here you can read it&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  #7 &lt;strong&gt;RAM (Repeat, Auto, MinMax):&lt;/strong&gt; grid-template-columns(auto-fit, minmax(, 1fr))
&lt;/h2&gt;

&lt;p&gt;In this seventh example, we'll take what we've learned about creating flexible layouts and add automatic placement of child elements. The result will be a responsive layout that adapts to different screen sizes and device orientations.&lt;/p&gt;

&lt;p&gt;To achieve this, we'll use a combination of CSS grid properties such as "repeat", "auto-fit" or "auto-fill", and "minmax()". These properties will allow us to define a flexible grid that automatically adjusts to the available space and distributes the child elements evenly. We can remember these properties using the acronym RAM, which stands for Repeat, Auto-fit/fill, and Minmax.&lt;/p&gt;

&lt;p&gt;The key advantage of this approach is that it saves us from having to manually calculate and set the size and position of each child element. Instead, we let the grid handle the layout, which makes it easier to maintain and update in the future.&lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="child-1"&amp;gt;My div 1&amp;lt;/div&amp;gt;
      &amp;lt;div class="child-2"&amp;gt;My div 2&amp;lt;/div&amp;gt;
      &amp;lt;div class="child-3"&amp;gt;My div 3&amp;lt;/div&amp;gt;
      &amp;lt;div class="child-4"&amp;gt;My div 4&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .parent {
  display: grid;
  height: 100vh;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.child-1 {
  display: grid;
  place-items: center;
  background: papayawhip;
}

.child-2 {
  display: grid;
  place-items: center;
  background: blueviolet;
}

.child-3 {
  display: grid;
  place-items: center;
  background: greenyellow;
}

.child-4 {
  display: grid;
  place-items: center;
  background: whitesmoke;
}

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

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/7-ram-repeat-auto-minmax-4n7tgf"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  #8 &lt;strong&gt;Line Up&lt;/strong&gt;: justify-content: space-between
&lt;/h2&gt;

&lt;p&gt;In the next layout example, we'll use the CSS property justify-content: space-between to position child elements in a Flexbox container. This property distributes the remaining space between the first and last elements of the container, while keeping them anchored to the edges of the box. The middle elements are then spaced evenly between the endpoints.&lt;/p&gt;

&lt;p&gt;We'll apply this technique to a set of cards that contain a title, a description, and an image block, arranged in a vertical column using the flex-direction: column property. This will create a visually pleasing layout where the title and image block are aligned with the top and bottom of the card, and the description is centered in between.&lt;/p&gt;

&lt;p&gt;By mastering this technique, you can create elegant and dynamic layouts that adapt to different screen sizes and orientations. Try experimenting with different values and settings to see how they affect the positioning and spacing of your child elements.&lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="card"&amp;gt;
        &amp;lt;h1&amp;gt;Card 1&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;This is a medium description.Share it.&amp;lt;/p&amp;gt;
        &amp;lt;div class="visual"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div class="card"&amp;gt;
        &amp;lt;h1&amp;gt;Card 2&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;
          This is a long description, thanks for read this post.
        &amp;lt;/p&amp;gt;
        &amp;lt;div class="visual"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div class="card"&amp;gt;
        &amp;lt;h1&amp;gt;Card 3&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;This is a short description&amp;lt;/p&amp;gt;
        &amp;lt;div class="visual"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .parent {
  display: grid;
  grid-gap: 1rem;
  grid-template-columns: repeat(3, 1fr);
}
.card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: papayawhip;
  padding: 1rem;
}

.visual {
  height: 100px;
  width: 100%;
  background: paleturquoise;
  margin: 0.5rem 0;
}

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

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/8-line-up-8c48c3"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  #9 &lt;strong&gt;Clamping My Style:&lt;/strong&gt; clamp(&amp;lt; min &amp;gt;, &amp;lt; actual &amp;gt;, &amp;lt; max &amp;gt;)
&lt;/h2&gt;

&lt;p&gt;In this example, we'll use the CSS function clamp() to set a range of sizes for an element, including a minimum and maximum value, as well as an actual size. This technique allows us to create more flexible and readable layouts that adapt to different screen sizes and device resolutions.&lt;/p&gt;

&lt;p&gt;For instance, we can use the clamp() function to set the width of an element to 50% of its parent, with a minimum of 23 character units and a maximum of 46 character units. This means that the element will stay centered in its parent and won't become too narrow or too wide, regardless of the viewport size.&lt;/p&gt;

&lt;p&gt;We can also use clamp() to set the font-size of text elements, such as headlines, to a range of values that scale with the viewport width. This way, the text will be readable on all devices, whether it's a small phone screen or a large desktop monitor.&lt;/p&gt;

&lt;p&gt;It's worth noting that the clamp() function is not supported in all modern browsers, so it's important to have fallback options and test your layout on different devices and browsers. Nonetheless, it's a powerful and versatile tool that can help you create more responsive and legible designs.&lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="card"&amp;gt;
        &amp;lt;h1&amp;gt;Card&amp;lt;/h1&amp;gt;
        &amp;lt;div class="visual"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;p&amp;gt;
          This is a description.
        &amp;lt;/p&amp;gt;
        &amp;lt;br /&amp;gt;
        &amp;lt;p&amp;gt;
          This is the content of the card. Here you can write a lot of text as
          you want.
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .parent {
  display: grid;
  place-items: center;
  height: 100vh;
}
.card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: papayawhip;
  padding: 1rem;
  width: clamp(23ch, 50%, 46ch);
}

.visual {
  height: 100px;
  width: 100%;
  background: paleturquoise;
  margin: 0.5rem 0;
}

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

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/9-clamping-my-style-6w6bt4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  #10 &lt;strong&gt;Respect for Aspect:&lt;/strong&gt; aspect-ratio: &amp;lt; width &amp;gt; / &amp;lt; height &amp;gt;
&lt;/h2&gt;

&lt;p&gt;Maintaining the aspect ratio of images and videos can be a challenge in web development, especially when dealing with responsive layouts. But there's a new CSS property called aspect-ratio that simplifies this task by letting you specify the desired aspect ratio of an element, such as 16:9 or 1:1, and allowing the browser to automatically adjust its size and shape accordingly.&lt;/p&gt;

&lt;p&gt;This property is particularly useful for videos and iframes, where preserving the original aspect ratio is critical. Previously, developers had to resort to padding hacks and complex calculations to achieve the same effect. But with aspect-ratio, you can achieve a similar result with much less code and hassle.&lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="card"&amp;gt;
        &amp;lt;h1&amp;gt;Card&amp;lt;/h1&amp;gt;
        &amp;lt;div class="visual"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;p&amp;gt;
          This is the description
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
  display: grid;
  place-items: center;
  height: 100vh;
}
.card {
  width: 80%;
  display: flex;
  flex-direction: column;
  background: lightblue;
  padding: 1rem;
}

.visual {
  aspect-ratio: 16/9;
  background: lightcoral;
  margin: 0.5rem 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/10-respect-for-aspect-d7vszt"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>programming</category>
      <category>html</category>
      <category>css</category>
      <category>layouts</category>
    </item>
    <item>
      <title>Ten Modern Layouts 🚀 [Part 2]</title>
      <dc:creator>Ernesto Herrera</dc:creator>
      <pubDate>Sat, 11 Feb 2023 23:51:50 +0000</pubDate>
      <link>https://dev.to/ernerdo/ten-modern-layouts-part-2-3o6o</link>
      <guid>https://dev.to/ernerdo/ten-modern-layouts-part-2-3o6o</guid>
      <description>&lt;p&gt;This is the second part of the "Ten Modern Layouts"&lt;br&gt;
&lt;a href="https://dev.to/ernerdo/ten-modern-layouts-part-1-a3m"&gt;If you aren't read the part 1, here you can read it&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  #4 Pancake Stack: grid-template-rows: auto 1fr auto
&lt;/h2&gt;

&lt;p&gt;This layout is often used for websites and apps.&lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="parent"&amp;gt;
      &amp;lt;header class="blue section" contenteditable&amp;gt;Header&amp;lt;/header&amp;gt;
      &amp;lt;main class="coral section" contenteditable&amp;gt;Main&amp;lt;/main&amp;gt;
      &amp;lt;footer class="purple section" contenteditable&amp;gt;Footer&amp;lt;/footer&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .parent {
  display: grid;
  height: 100vh;
  grid-template-rows: auto 1fr auto;
}
header {
  background: rgb(235, 108, 127);
  padding: 2rem;
  text-align: center;
}

main {
  background: lightgreen;
  padding: 2rem;
  text-align: center;
}

footer {
  background: rgb(14, 202, 202);
  padding: 2rem;
  text-align: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/pancake-stack-6t11i5"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  #5 Classic Holy Grail Layout: grid-template: auto 1fr auto / auto 1fr auto
&lt;/h2&gt;

&lt;p&gt;It is similar to the previous layout, but now with sidebars&lt;br&gt;
HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;header class="pink section"&amp;gt;Header&amp;lt;/header&amp;gt;
      &amp;lt;div class="left-side blue section" contenteditable&amp;gt;Left Sidebar&amp;lt;/div&amp;gt;
      &amp;lt;main class="section coral" contenteditable&amp;gt;Main&amp;lt;/main&amp;gt;
      &amp;lt;div class="right-side yellow section" contenteditable&amp;gt;Right Sidebar&amp;lt;/div&amp;gt;
      &amp;lt;footer class="green section"&amp;gt;Footer&amp;lt;/footer&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
  display: grid;
  height: 100vh;
  grid-template: auto 1fr auto / auto 1fr auto;
}

header {
  padding: 2rem;
  background: plum;
  grid-column: 1 / 4;
}

.left-side {
  padding: 2rem;
  background: purple;
  grid-column: 1 / 2;
}

main {
  padding: 2rem;
  background: paleturquoise;
  grid-column: 2 / 3;
}

.right-side {
  padding: 2rem;
  background: papayawhip;
  grid-column: 3 / 4;
}

footer {
  padding: 2rem;
  background: palegreen;
  grid-column: 1 / 4;
}

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

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/classic-holy-grail-layout-m36yj0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  #6 12-Span Grid: grid-template-columns: repeat(12, 1fr)
&lt;/h2&gt;

&lt;p&gt;The next item on our list is a timeless favourite: the 12-column grid. You can easily create grids in CSS using the repeat() function. By specifying repeat(12, 1fr) as the grid template columns, you'll get 12 equal-width columns each taking up 1 fraction unit of the available space.&lt;br&gt;
HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="span-12"&amp;gt;Span 12&amp;lt;/div&amp;gt;
      &amp;lt;div class="span-6"&amp;gt;Span 6&amp;lt;/div&amp;gt;
      &amp;lt;div class="span-4"&amp;gt;Span 4&amp;lt;/div&amp;gt;
      &amp;lt;div class="span-2"&amp;gt;Span 2&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
  display: grid;
  height: 100vh;
  grid-template-columns: repeat(12, 1fr);
}
.span-12 {
  background: lightpink;
  grid-column: 1 / 13;
}

.span-6 {
  background: lightblue;
  grid-column: 1 / 7;
}

.span-4 {
  background: coral;
  grid-column: 4 / 9;
}

.span-2 {
  background: yellow;
  grid-column: 3 / 5;
}


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

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/12-span-grid-mv3kc4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>webperf</category>
      <category>automation</category>
      <category>deployment</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Ten Modern Layouts 🚀 [Part 1]</title>
      <dc:creator>Ernesto Herrera</dc:creator>
      <pubDate>Wed, 21 Dec 2022 03:03:49 +0000</pubDate>
      <link>https://dev.to/ernerdo/ten-modern-layouts-part-1-a3m</link>
      <guid>https://dev.to/ernerdo/ten-modern-layouts-part-1-a3m</guid>
      <description>&lt;p&gt;This is the first part of the "Ten Modern Layouts"&lt;/p&gt;

&lt;h3&gt;
  
  
  #1 Super Centered: place-items: center
&lt;/h3&gt;

&lt;p&gt;One of the main day-to-day challenges in front end development is to center elements, the best way to do it is using flex or grid as shown in the following example.&lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="box" contenteditable&amp;gt;
        Hello, 👋😎
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS -&amp;gt; Using Grid&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
  display: grid;
  place-items: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS -&amp;gt; Using Flex&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent-flex {
  display: flex;
  place-items: center;
  justify-content: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/super-centered-oq5kpx"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  #2 The Deconstructed Pancake: flex:   
&lt;/h2&gt;

&lt;p&gt;This is a common layout for marketing sites, which may have a row of 3 items, like image, title and description. On mobile, we'll want those three sections to stack nicely, and expand as the screen size increases. &lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="child-streching"&amp;gt;one&amp;lt;/div&amp;gt;
      &amp;lt;div class="child-streching"&amp;gt;two&amp;lt;/div&amp;gt;
      &amp;lt;div class="child-streching"&amp;gt;three&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="space"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="child-no-streching"&amp;gt;one&amp;lt;/div&amp;gt;
      &amp;lt;div class="child-no-streching"&amp;gt;two&amp;lt;/div&amp;gt;
      &amp;lt;div class="child-no-streching"&amp;gt;three&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .parent {
  background-color: bisque;
  display: flex;
  flex-wrap: wrap;
}
.space {
  background-color: white;
  height: 100px;
}
.child-streching {
  flex: 1 1 300px;
  border: 1px solid red;
  background: lightpink;
  font-size: 2rem;
  text-align: center;
}
.child-no-streching {
  flex: 0 1 300px;
  border: 1px solid blueviolet;
  background: papayawhip;
  font-size: 2rem;
  text-align: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/the-deconstructed-pancake-9gu75j"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  #3 Sidebar Says:grid-template-columns: minmax(,)...)
&lt;/h2&gt;

&lt;p&gt;This demo uses the minmax function to create a grid layout. We're setting the minimum sidebar size to 200px, but on larger screens, it can stretch out to 30%. The sidebar will always take up 30% of its parent's horizontal space, unless that 30% becomes smaller than 200px.&lt;/p&gt;

&lt;p&gt;HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="parent"&amp;gt;
      &amp;lt;div class="section-blue" contenteditable&amp;gt;
        Min: 200px / Max: 30%
      &amp;lt;/div&amp;gt;
      &amp;lt;div class="section-green" contenteditable&amp;gt;
        This element takes the second grid position (1fr), meaning it takes up
        the rest of the remaining space.
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
  display: grid;
  grid-template-columns: minmax(200px, 30%) 1fr;
}
.section-blue {
  background-color: skyblue;
}
.section-green {
  background-color: darkgreen;
  color: white;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/sidebar-says-grid-template-columns-d9u56l"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/ernerdo/ten-modern-layouts-part-2-3o6o"&gt;here you can read part 2&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Asynchronism in JavaScript</title>
      <dc:creator>Ernesto Herrera</dc:creator>
      <pubDate>Sat, 10 Dec 2022 03:29:42 +0000</pubDate>
      <link>https://dev.to/ernerdo/asynchronism-in-javascript-471a</link>
      <guid>https://dev.to/ernerdo/asynchronism-in-javascript-471a</guid>
      <description>&lt;p&gt;JavaScript is a popular programming language used in most modern websites and applications. One of its most important features is its ability to handle asynchronous tasks, which allows applications to multitask without blocking UI performance.&lt;/p&gt;

&lt;p&gt;Asynchronisms in JavaScript rely on a feature called "running in the background." This means that while one task is running on the main JavaScript thread, other tasks can run in the background, allowing the application to continue running smoothly without interruption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Callbacks
&lt;/h2&gt;

&lt;p&gt;JavaScript's callbacks are functions that are passed as an argument to other functions and are executed when a certain event occurs or when an asynchronous operation is completed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example of asynchronism
//callback
function printResult(result) {
  console.log(result)
}

function sumNumbers(myCallback,...nums) {
 let result = 0;
  for( let num of nums){
    result += num
 }
  myCallback(result);
}

sumNumbers(printResult,5,8,9);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Promises
&lt;/h2&gt;

&lt;p&gt;Promises allow us to handle asynchronous more easily in JavaScript by giving us a way to specify what actions to take when an asynchronous operation completes or fails. This allows us to write code that is easier to read and maintain, since we don't need to nest our code in a series of if and else blocks like in synchronous languages.&lt;/p&gt;

&lt;p&gt;A promise can be in one of three states: pending, fulfilled, or rejected. When an asynchronous operation starts, a promise is created that is in the pending state. When the operation completes, the promise becomes fulfilled and the result of the operation is provided. If the operation fails, the promise is converted to rejected and a reason for failure is provided.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const requestPermission = new Promise((resolve, reject) =&amp;gt; {
// We wait a second before resolving the promise
setTimeout(() =&amp;gt; {
// We resolve the promise with the value "approve"
resolve("approve");
}, 1000);
});

console.log("Begin");

// Once the promise has been resolved, we print the resolve value to the console
requestPermission.then((resolve) =&amp;gt; {
console.log(resolve);
});

console.log("finish");


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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Async / Await
&lt;/h2&gt;

&lt;p&gt;Another way to handle asynchronous tasks in JavaScript is by using the "async/await" method. This method allows you to write asynchronous code synchronously, making it more readable and easy to understand. To use the "async/await" method, you must mark a function as "async" and use the "await" keyword to wait for a promise to be fulfilled before continuing with code execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// without  asycn await

const getNameAsync = () =&amp;gt; {
// Wait 4 seconds before printing the value to the console
setTimeout(() =&amp;gt; {
console.log("jose");
}, 4000);
};

// Declare the printNameAsync function as asynchronous
async function printNameAsync() {
console.log("calling");

// We execute the getNameAsync function and store the result in a variable
const message = getNameAsync();

// Print the value of the variable
console. log(message);
console.log("end");
}

// We execute the function
printNameAsync();
//calling
//undefined
//end
//jose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// with asycn await

const getNameSync = () =&amp;gt; {
return new Promise((resolve) =&amp;gt; {
// We wait 4 seconds before resolving the promise
setTimeout(() =&amp;gt; {
// We resolve the promise with the value "jose"
resolve("jose");
}, 4000);
});
};

// We declare the printNameSync function as asynchronous
async function printNameSync() {
console.log("calling");

// We wait for the promise returned by getNameSync to resolve
const message = await getNameSync();

// We print the resolution value of the promise
console.log(message);
console.log("end");
}

// We execute the function
printNameSync();
//calling
//jose
//end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Asynchronisms in JavaScript are an indispensable feature that allows applications to handle multiple tasks at the same time without affecting the performance of the user interface. Knowing the different ways to handle asynchronous tasks in JavaScript is an essential skill for any modern web application developer.&lt;/p&gt;

&lt;p&gt;Thank you very much for reading my article. I hope it has been of interest to you and that you have learned something new on the subject. I love writing about technology and programming, and I'm glad to share my knowledge and experiences.&lt;/p&gt;

&lt;p&gt;If you have any questions or comments about the article, feel free to leave your comments, I would love to read your opinion.&lt;/p&gt;

&lt;h4&gt;
  
  
  Reference
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://platzi.com/cursos/asincronismo-js/"&gt;Platzi Asincronismo&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/es/docs/Learn/JavaScript/Asynchronous"&gt;MDN&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Learn ECMAScript 6 from Beginner to advanced 🚀</title>
      <dc:creator>Ernesto Herrera</dc:creator>
      <pubDate>Wed, 07 Dec 2022 04:20:13 +0000</pubDate>
      <link>https://dev.to/ernerdo/learn-ecmascript-6-from-beginner-to-advanced-hm2</link>
      <guid>https://dev.to/ernerdo/learn-ecmascript-6-from-beginner-to-advanced-hm2</guid>
      <description>&lt;p&gt;What is it ECMAScript?&lt;br&gt;
Is a scripting language specification on which JavaScript is based. &lt;a href="https://www.ecma-international.org/" rel="noopener noreferrer"&gt;Ecma International&lt;/a&gt; is in charge of standardizing ECMAScript.&lt;/p&gt;

&lt;p&gt;There is a lot of new function added to JavaScript, in this post we are going to see the most value feature.&lt;/p&gt;
&lt;h2&gt;
  
  
  Default parameters and concatenation using template literals
&lt;/h2&gt;

&lt;p&gt;Function parameter with default values are initialized with default values if they not contain value or are undefined.&lt;/p&gt;

&lt;p&gt;Template literals provide an easy way to interpolate variables and expressions into strings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function printMessage(message = 'default'){
  if (message !== 'default'){
    return `Custom message with this value: ${message}`
  }

  return `Hello, this is ${message} message`
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Let and const
&lt;/h2&gt;

&lt;p&gt;ES6 Conventions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;const&lt;/code&gt; by default.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;let&lt;/code&gt; if you have to rebind a variable.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; can be redeclared and reassigned.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; can be reassigned, but not redeclared.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;const&lt;/code&gt; can not be redeclared and reassigned.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7c3y9e1bm4ng7q1wc3rw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7c3y9e1bm4ng7q1wc3rw.png" alt="Table comparation const, let and var" width="800" height="415"&gt;&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;var a = 10;
console.log(a); //10
{
  let a = 2;
  console.log(a); //2
}
console.log(a); //10

var b = 10;
console.log(b)// Here b is 10
{
  const b = 2;
  console.log(b)// Here b is 2
}
console.log(b)// Here b is 10

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Arrow Functions
&lt;/h2&gt;

&lt;p&gt;Arrow functions are not hoisted. They must be defined before they are used.&lt;br&gt;
It is recommended to use &lt;code&gt;const&lt;/code&gt; for &lt;code&gt;arrow functions&lt;/code&gt;, because a function expression is always a constant value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const sumData = (a,b) =&amp;gt; a + b;

console.log(sumData(23,4)); // 27
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Spread (...) Operator
&lt;/h2&gt;

&lt;p&gt;It allows us to quickly copy all or part of an existing array or object into another array or object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const pokemonKanto = ['pikachu','zubat'];
const pokemonHoenn = ['torchid','latios'];

const listPokemonAllRegion = [...pokemonKanto,...pokemonHoenn]

console.log(listPokemonAllRegion); // ["pikachu", "zubat", "torchid", "latios"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Destructuring
&lt;/h2&gt;

&lt;p&gt;The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [a, b] = ["hello", "Jose"];
console.log(a); // "hello"
console.log(b); // "jose"

const obj = { nombre: "Jose", apellido: "Silva" };
const { nombre, apellido } = obj;
console.log(nombre,apellido); // "Jose Silva"

const getYearAndMonth = function () {
  return ["2022", "December"];
};
const [year, month] = getYearAndMonth();
console.log(year); //2022
console.log(month); //December

const getPokemon = function () {
  return {
    name:'pikachu',
    trainner:'Ash',
  };
};
const {name,trainner} = getPokemon();
console.log(name); //pikachu
console.log(trainner); //Ash

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  The For/Of Loop
&lt;/h2&gt;

&lt;p&gt;This is a new way for iterable array&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function printAllNames(...names) {
  let listOfName = 'list of name: ';
  for (let name of names){
   listOfName += name + " ";
  } 
  return listOfName;

}

let result = printAllNames('pablo','jose','ernesto','');

console.log(result); //list of name: pablo jose ernesto
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Rest Parameter
&lt;/h2&gt;

&lt;p&gt;The rest parameter syntax allows a function to accept an indefinite number of arguments as an array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function multiply(...values) {
  let operation = 1;
  for (let value of values){
    operation *= value;
  } 
  return operation;

}

let result = multiply(1,2,3,4,5,6);

console.log(result); //720
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Classes
&lt;/h2&gt;

&lt;p&gt;JavaScript Classes are templates for JavaScript Objects.&lt;br&gt;
Use the keyword class to create a class.&lt;br&gt;
Always add a method named constructor():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class PlayerSoccer {
  constructor(name, selection) {
    this.name = name;
    this.selection = selection;
  }
}

const playerOne = new PlayerSoccer('messi','argentina');
const playerTwo = new PlayerSoccer('ronaldo', 'portugal');

console.log(playerOne); //PlayerSoccer {name: "messi", selection: "argentina", constructor: Object}
console.log(playerTwo); //PlayerSoccer {name: "ronaldo", selection: "portugal", constructor: Object}
export { PlayerSoccer };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Modules
&lt;/h2&gt;

&lt;p&gt;Modules are imported in two different ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Import a default export from the file pokemon.js:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default class Pokemon {
  constructor(name, type) {
    this.name = name;
    this.type = type;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Import named exports from the file vehicle.js
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car {
  constructor(brand, model, year) {
    this.brand = brand;
    this.model = model;
    this.year = year;
  }
}

class Bike {
  constructor(brand, model, year) {
    this.brand = brand;
    this.model = model;
    this.year = year;
  }
}
export { Car, Bike };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Pokemon from "./pokemon";
import { Car, Bike } from "./vehicle";

const firstPokemon = new Pokemon("pikachu", "electric");
console.log(firstPokemon);

const firstCar = new Car("Toyota", "yaris", 2020);
console.log(firstCar);

const firstBike = new Bike("Suzuki", "gixxer", 2021);
console.log(firstBike);


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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Sets
&lt;/h2&gt;

&lt;p&gt;A JavaScript Set is a collection of unique values.&lt;br&gt;
Each value can only occur once in a Set.&lt;br&gt;
A Set can hold any value of any data type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const words = new Set();

words.add('a');
words.add('b');
words.add('a');
console.log(words); //a,b

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Promises
&lt;/h2&gt;

&lt;p&gt;Promise is the easiest way to work with asynchronous programming in JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myPromise = () =&amp;gt; {
  return new Promise((resolve, reject) =&amp;gt; {
      if(true) {
          resolve( "success" )
      }
      else{
          reject( "error" )
      }
    });
}

myPromise()
.then( response =&amp;gt; console.log(response) ) // case success
.catch( error =&amp;gt; console.log(error) ) //case error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Time to practice 💪🏻
&lt;/h2&gt;

&lt;p&gt;This is the end of the post and the most exciting part, now it's your turn to put top practice es6 into practice, here I leave you a codesandbox ready for you to write your code. Remember to fork the codesandbox to save your practice.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/recursing-tree-yxsxb1"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Any questions you have, do so in the comments and I will gladly answer all of them. I also share some links where we can delve deeper into the ECMAScript 6.&lt;/p&gt;

&lt;h4&gt;
  
  
  References
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.w3schools.com/js/js_es6.asp" rel="noopener noreferrer"&gt;w3schools&lt;/a&gt;&lt;br&gt;
&lt;a href="https://platzi.com/cursos/ecmascript-6/" rel="noopener noreferrer"&gt;Platzi Curso de ECMAScript: Historia y Versiones de JavaScript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>cpp</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
