Destructuring in ES6

Learn JSDestructuring is a very useful newer feature of javascript.  I’ve been using it for more than a year but I never sat down and looked at its details.  How did this come up?  I got a reference to this video from one of my weekly e-newsletters;  its about ten minutes and goes quickly from a simple example of

// Destructuring objects, simple case

let obj={ a: 3, b: 5 };

let { a, b } = obj;   // New syntax for a=obj.a; b=obj.b;

to the headscratcher:

// Destructuring function arguments

function f( L1, L2 ) {

  // ...

}

f( R1, R2 );

[L1, L2] = [R1, R2]; //

I was very unclear what this last example was doing which made me realize I’d only touched the tip of the iceberg as far as this feature was concerned.  The video was over and I still didn’t understand it.  I decided to watch the next video that Youtube so kindly recommended.  Its this one by that wacky FunFunFunction guy.

He spent most of the video on what I call the simple case above, with the notable exception of showing destructuring used in a function argument declaration, with default values – a widespread pattern now among ReactJS coders:

// One parameter which is an object is passed in, and two of its properties are destructured

function ModalName({ onClickNext, step ='whatever' }) {
  return (
   <div>
     <h1>Step {step} - Name</h1>
     <Button onClick={onClickNext}>Next</Button>
   </div>
  );
 }

I also found this article which lists ES6 features frequently seen in ReactJS development.

 

Raspberry Pi in box

Raspberry Pi – My introduction to hardware

Raspberry Pi in boxI just got a Raspberry Pi 2. I don’t really know what to do with it yet!  Its a itty-bitty linux box.   I’m used to writing code but hardware is a whole unknown world to me.  This is my dive into the world of the Internet of Things, robots, drones, smart devices, and electronic dyi gadgetry in general.

Join me as I learn and twiddle.

Continue reading Raspberry Pi – My introduction to hardware

Blood tests

8 Better Tests for Heart Disease Than Cholesterol

As a marker for the presence and severity of Heart Diseases, total cholesterol and the division of cholesterol into good HDL and bad LDL is out of date.  There are at least 8 tests that have higher significance and show better correlation with heart disease.

Continue reading 8 Better Tests for Heart Disease Than Cholesterol

soy

Your Thyroid Hates Soy

Soy is not good food because it disturbs your hormones.  It is goitrogenic, meaning it can suppress thyroid gland functions, which can result in problems like goiter, thyroid enlargement, and related thyroid diseases.  The only safe use of soy as food is in a fermented form (like tofu) as a small part of the diet – and never for babies.

Continue reading Your Thyroid Hates Soy

Banned Poisons Still Allowed in Common U.S. Foods

The United States allows ingredients in our packaged and prepared foods that have been banned in many other countries!  In this article I’ll outline some ingredients you will find in common store bought foods that should raise your eyebrows.   Hopefully you’ll decide to put aside these products with poisons posing as foods.

Continue reading Banned Poisons Still Allowed in Common U.S. Foods

Treat Asthma Naturally

asthmaticThere is quite a bit you can do to prevent and treat asthma naturally.  If your diagnosis is established always have your inhaler handy – that’s just common sense.   Aside from that, here I teach you some crucial information about how to address asthma, especially through diet.

Continue reading Treat Asthma Naturally