<?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: Maryam hosseini</title>
    <description>The latest articles on DEV Community by Maryam hosseini (@maryam_hosseini_e3effa8e8).</description>
    <link>https://dev.to/maryam_hosseini_e3effa8e8</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%2F1502471%2F3b579a30-3cdb-4fa2-a80a-c9a8a0b828ee.jpg</url>
      <title>DEV Community: Maryam hosseini</title>
      <link>https://dev.to/maryam_hosseini_e3effa8e8</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/maryam_hosseini_e3effa8e8"/>
    <language>en</language>
    <item>
      <title>Methods and primitive type in JS</title>
      <dc:creator>Maryam hosseini</dc:creator>
      <pubDate>Wed, 19 Nov 2025 04:08:06 +0000</pubDate>
      <link>https://dev.to/maryam_hosseini_e3effa8e8/methods-and-primitive-type-in-js-4e0o</link>
      <guid>https://dev.to/maryam_hosseini_e3effa8e8/methods-and-primitive-type-in-js-4e0o</guid>
      <description>&lt;p&gt;JavaScript is designed on an object-based paradigm.&lt;br&gt;
An object is a collection of properties.&lt;br&gt;
Method is a property of an object that contains a function definition.So methods are actions that can be performed on object.&lt;br&gt;
The question that arises here is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How we use methods on primitives type🤔?&lt;/li&gt;
&lt;li&gt;How does JavaScript handle them?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's go deep into it.🤗✌️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primitive values&lt;/strong&gt;&lt;br&gt;
All types except Object define immutable values represented directly at the lowest level of the language. We refer to values of these types as primitive values.&lt;br&gt;
We have 7 primtives type in JS:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;null&lt;/li&gt;
&lt;li&gt;undefined&lt;/li&gt;
&lt;li&gt;string&lt;/li&gt;
&lt;li&gt;number&lt;/li&gt;
&lt;li&gt;bigint&lt;/li&gt;
&lt;li&gt;boolean&lt;/li&gt;
&lt;li&gt;symbol&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let message="hello";
console.log(message.toUpperCase());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;We said methods are actions that can be performed on object.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But string is a primitive type so the JS engine highly optimize this process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JavaScript automatically boxes primitives into relevant objects when it encounters method calls on them.(Boxing)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That method runs and returns a new value.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const message=new String("hello");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The special object is destroyed, leaving the primitive string alone.(UnBoxing)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The "object wrappers" are different for each primitive type  and are called: &lt;strong&gt;String&lt;/strong&gt;, &lt;strong&gt;Number&lt;/strong&gt;, &lt;strong&gt;Boolean&lt;/strong&gt;, &lt;strong&gt;Symbol&lt;/strong&gt; and &lt;strong&gt;BigInt&lt;/strong&gt;. Thus they provide different sets of methods.&lt;/p&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%2Fhfzy5xpaza3hrm0520i5.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%2Fhfzy5xpaza3hrm0520i5.png" alt=" " width="738" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Null and undefined have no methods&lt;/strong&gt;&lt;br&gt;
The special primitives &lt;strong&gt;null&lt;/strong&gt; and &lt;strong&gt;undefined&lt;/strong&gt; are exceptions. They have no corresponding “wrapper objects” and provide no methods. In a sense, they are “the most primitive”.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Memory Leaks in JavaScript</title>
      <dc:creator>Maryam hosseini</dc:creator>
      <pubDate>Sun, 10 Aug 2025 22:54:12 +0000</pubDate>
      <link>https://dev.to/maryam_hosseini_e3effa8e8/memory-leaks-in-javascript-1li5</link>
      <guid>https://dev.to/maryam_hosseini_e3effa8e8/memory-leaks-in-javascript-1li5</guid>
      <description>&lt;p&gt;JavaScript automatically allocates memory when objects are created and frees it when they aren't used anymore(Garbage Collection).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Memory leak&lt;/strong&gt; in JavaScript is a part of the memory that no longer, but is still kept by the program and is not released by the Garbage Collector. This makes the program consumption more and more and eventually slows down or even crashing the program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Allocation in JavaScript
&lt;/h2&gt;

&lt;p&gt;JavaScript will automatically allocate memory when values are initially declared.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Allocates memory for a number
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const num=567;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Allocates memory for a string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const text="description";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Allocates memory for an object and contained values&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const person={
name:"maryam",
age:30
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Allocates memory for the array&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const colors=["red","green","blue"];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.Allocates memory for a function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sum(a,b){
return a+b;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6.Allocates memory for an eventListener&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;divElement.addEventListener("click",()=&amp;gt;{
divElement.style.backgroundColor="blue";
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;7.Allocates memory for a Date 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 dateNow=new Date();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reason for Memory Leak
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the Garbage Collector only releases an object when there is no refrence.&lt;br&gt;
 If you unintentionally hold the refers to an object, that object will never be released.&lt;br&gt;
1.Global variables unwanted&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function foo() {
  leakVar = "I am leaked"; // without let/const/var → global
}
foo();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This variable remains in the entire life of the program.&lt;/p&gt;




&lt;p&gt;2.References in Closures&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function createLeak () {
let Bigdata = New Array (1000000) .fill ("Leak");  
return function () {
console.log (Bigdata [0]);  
}; 
 } 
const leaky = createLeak ();  // Bigdata is still holding
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because Closure still refers to Bigdata, memory is not released.&lt;/p&gt;




&lt;p&gt;3.Events uninvited Listener&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Attach () {
   consting instant = document.getElementById ("BTN");
   element.addEventListener ("click", () =&amp;gt; console.log ("click!");
   // If the element is deleted but the listener is not erased → leak
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even after eliminating the Element from the DOM, the memory will not be released if the Listener is not erased.&lt;/p&gt;




&lt;p&gt;4.Objects stored in data structures (such as Map/Set) that are not deleted&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const cache = new map ();  function addCache (Key, Value) {
cache.set (key, value);  // If the Keys are not deleted → leak
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Ways to prevent Memory Leak
&lt;/h2&gt;

&lt;p&gt;1.Limit the Global variables (always use let, const or var).&lt;/p&gt;

&lt;p&gt;2.Wipe the Event Listener after use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;element.removeEventListener("click", handler); //Null or delete in time.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.In data stations like MAP and SET, delete it if data is no longer necessary.&lt;/p&gt;

&lt;p&gt;4.For temporary data, use weakmap and weakset that automatically release memory.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Use &amp; in css</title>
      <dc:creator>Maryam hosseini</dc:creator>
      <pubDate>Thu, 03 Apr 2025 11:23:25 +0000</pubDate>
      <link>https://dev.to/maryam_hosseini_e3effa8e8/use-in-css-1cd3</link>
      <guid>https://dev.to/maryam_hosseini_e3effa8e8/use-in-css-1cd3</guid>
      <description>&lt;p&gt;Hey everyone👋&lt;br&gt;
When we want to create our web pages we use HTML.It describes the structure of a web page and consists of a series of elements.&lt;br&gt;
Css is a stylesheet language used to describes how elements should be rendered on screen, on paper etc.&lt;br&gt;
We can use of &lt;strong&gt;&amp;amp;&lt;/strong&gt; nesting selector to set style for our elements.&lt;br&gt;
There are different ways to use of it, such as:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Set style for whole document&lt;/strong&gt;
The &lt;strong&gt;&amp;amp;&lt;/strong&gt; nesting selector set style for all of elements in document.(when we didn't use of class name  before or after that).
For example:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;amp;{
   font-size:16px;
   color:blue;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;2.&lt;strong&gt;Set style for parent and child elements&lt;/strong&gt;&lt;br&gt;
When we want to set style for the below example:&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;p class="parent"&amp;gt;
  This is a 
  &amp;lt;span class="child"&amp;gt;
    simple example
  &amp;lt;/span&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maybe we use this syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent{
   color:black;
   font-size:18px;
}
.parent .child{
   color:white;
   font-weight:800;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but with uses nested css styling, we write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent{
  color:black;
  font-size:18px;
  &amp;amp; .child{
      color:white;
      font-weight:800;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;br&gt;
Whitespace is very important in this syntax.&lt;br&gt;
If we set whitespace between &lt;strong&gt;&amp;amp;&lt;/strong&gt; and .child(&amp;amp; .child)it sets styles for all child elements with child class name but when we remove whitespace(&amp;amp;.child)it means set styles for the element with both class name, parent and child, For example:&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;p class="parent child"&amp;gt;
    This is a 
    &amp;lt;span&amp;gt;simple example&amp;lt;/span&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In addition to using personal classes we can use &lt;strong&gt;&amp;amp;&lt;/strong&gt; with pseudo-class and compound selectors, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent{
  color:black;
  font-size:18px;
  &amp;amp;:hover{
      color:white;
      font-weight:800;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Till now we've added &lt;strong&gt;&amp;amp;&lt;/strong&gt; at the begining of the class name, that's while we can add it after the class name, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent{
  color:black;
  font-size:18px;
  .child &amp;amp;{
      color:white;
      font-weight:800;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will compiled:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent{
  color:black;
  font-size:18px;
}
.child .parent{
   color:white;
   font-weight:800;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;br&gt;
We can add multi &lt;strong&gt;&amp;amp;&lt;/strong&gt; in this syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent{
  color:black;
  font-size:18px;
  .child &amp;amp; &amp;amp; &amp;amp;{
      color:white;
      font-weight:800;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will compiled:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent{
  color:black;
  font-size:18px;
}
.child .parent .parent .parent{
   color:white;
   font-weight:800;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
All of the examples produce the same output.Some of them are normal css styles that we usually use in our projects and the other one uses the &lt;strong&gt;&amp;amp;&lt;/strong&gt; nesting selector.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
    </item>
  </channel>
</rss>
