Code Monkey home page Code Monkey logo

dict.js's Introduction

dict.js

dict.js adds a dictionary class to javaScript

In a dictionary (also called associative array) you can acces objects of an array through a key, which can be a number as well as a string. Thats why you call them key➡value pairs. Dictionaries are used in Python, Java, PHP and many other programming languanges but not in JS! So enjoy this little code snippet.


  • use new dict() to create a dict object
  • use add(key, value) to add a key-value-pair (keys have to be unique)
  • use getByKey(key) to get a value by its key

  • use length to get the number of keys (which should also be the number of values)

  • use k(key) as an alias for getByKey()


example workflow

var myDict = new dict();
myDict.add("gitHub", "awesome");
myDict.add("coding", "too");
console.log(myDict.k("coding"));
alert("Dict's length is "+myDict.length)

keep on coding ⌨




© Moritz Mockenhaupt 2020

\ ゜ o ゜)ノ

dict.js's People

Contributors

mopamo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.