Broad Network

ECMAScript Collection Insecurities and Prevention

ECMAScript Insecurities and Prevention Part 4

ECMAScript 6

Foreword: In this part of the series, I explain the insecurities with collections and how to prevent them.

By: Chrysanthus Date Published: 16 Jul 2016


This is part 4 of my series, ECMAScript Insecurities and Prevention. In this part of the series, I explain the insecurities with collections and how to prevent them. You should have read the previous parts of the series before coming here, as this is a continuation.

A collection is an array, a set or a map. I use a map for illustration. A similar analysis can be used for an array or set. The map is created from a two dimensional array.

Initial Data
The initial data for the map is the following fruit/color data:

Apple, purple
Banana, yellow
Pear, green

Map Creation
The following code creates the map:

    mapObj = new Map();

    mapObj.set('Apple ', "purple");
    mapObj.set('Banana', "yellow");
    mapObj.set('Pear', "green");

The problem with a collection is that the values of the elements can be deleted, changed and the number of elements can be increased.

As of now, there is no official way to keep the values of a collection, fixed (locked). The fundamental solution is to re-code all the key/value pairs in constant statements as follows:

const Apple = "purple";
const Banana = "yellow";
const Pear = "green";
That is it for this part of the series. We stop here and continue in the next part.


Related Links

ECMAScript Basics
ECMAScript Operators
Expressions in ECMAScript
Statements in ECMAScript
Custom Objects in ECMAScript
Functions in ECMAScript
ECMAScript Date Object
The ECMAScript String Object
ECMAScript String Regular Expressions
ECMAScript Template Literal
The ECMAScript Array
ECMAScript Sets and Maps
ECMAScript Number
Scopes in ECMAScript
Mastering the ECMAScript (JavaScript) eval Function
Sending Email with ECMAScript
ECMAScript Insecurities and Prevention
Advanced Course
Advanced ECMAScript Regular Expressions
Promise in ECMAScript 2015
Generator in ECMAScript 2015
ECMAScript Module
More Related Links
Node Mailsend
Node.js Web Development Course
Major in Website Design
Low Level Programming - Writing ECMAScript Module
ECMAScript Course



Become the Writer's Follower
Send the Writer a Message