Today I have learned map in javascript

 map in javascript

The map is a collection of elements where each element is stored as a Key, value pair. Map objects can hold both objects and primitive values as either key or value. When we iterate over the map object it returns the key, and value pair in the same order as inserted. Map() constructor is used to create Map in JavaScript.

Map object provided by ES6. A key of a Map may occur once, which will be unique in the map’s collection. There are slight advantages to using a map rather than an object.

  • Accidental Keys & Security: No default keys are stored, only contain what’s explicitly put into them. Because of that, it’s safe to use.
  • Key Types & Order: It can be any value as a key function, object anything. And the order is straightforward way in the order of entry insertion.
  • Size: Because of the size property a map can be easily retrieved.
  • Performance: Any operation can be performed on math so easily in a better way.
  • Serialization and parsing: We can create our own serialization and parsing support for Map by using JSON.stringify() and JSON.parse() methods.
import icon from "../images/react.jpg"
import "../project/dhisha.css";
function Vaishal (){
    const day=["Monday", " Tuesday", " wednesday", " Thursday", " Friday", " saturday", " Sunday"]
    return(
        <div>
            <img className="java2" src={icon}></img>
            <h2 className="java3">React js</h2>
            <a href="/project">React is a programming language</a>
            {day.length>0 &&
    <h1>total {day.length} days</h1>}  
    <h2 className="blue">{day.map((a)=>(a))}</h2>
        </div>
    )
}
export default Vaishal;

.blue{
    color: blue;
    text-transform: uppercase;
}
OUTPUT:


Comments

Popular posts from this blog

Building a Full-Stack Student Management System with React.js and NestJS

Today I have solved the problem in javascript

Today I have solved problem in javascript