Hey devs - have you seen this before - parameters done two ways?

zimlearn

Dr Abstract

Posted on December 3, 2020

Hey devs - have you seen this before - parameters done two ways?

An honest question. We find it very very handy to be able to provide arguments to classes, methods and functions in two different ways. The first is parameters as usual in order. The second is a single parameter that is an object literal (config object) where the properties match the parameter names.

So we are wondering if any framework out there other than ZIM has this ability. It was tricky to code but we have open sourced it. I swear - it is so handy and all that use ZIM love it.

// traditional parameters in order:
const rect = new Rectangle(100, 100, red, null, null, 20);

// or as a configuration object:
const rect = new Rectangle({
   width:100, 
   height:100, 
   color:red, 
   corner:20
});
Enter fullscreen mode Exit fullscreen mode

This allows ZIM to provide a lot of parameters - take a look at our docs: https://zimjs.com/docs

I would say, half the time I use one way and half the time I use the other. That really proves that it is handy.

Cheers! Any comments or questions are welcome.


If you have not checked out the Canvas recently - you simply must! Here is the ZIM Dev Site and some In-depth Guides by Dr Abstract including Your Guide to Coding Creativity on the Canvas.

💖 💪 🙅 🚩
zimlearn
Dr Abstract

Posted on December 3, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related