Variables inside JavaScript Functions

“It doesn’t matter where I declare my variables, right? They just get hoisted….. right?”
~ what this developer had to be thinking right before they committed this code.
Not so fast. Let’s just do a simple test using the developer tools to see whether JavaScript hoists inside functions.

function testy(){
  if(testy===true){
    console.log("It's true! I'm testy!")
  } else { 
    console.log("I'm not testy today")
  }
  var testy = true
}

Before I go showing the answer, what do you think the console shows?

.

.

.

.

.

.

.

.

Screen Shot 2018-09-18 at 9.09.42 PM

 

So it looks like JavaScript does not hoist variable declarations inside of functions. Let’s double check that with a quick change.

function testy(){
  var testy = true
  if(testy===true){
    console.log("It's true! I'm testy!")
  } else {
    console.log("I'm not testy today")
  }
}

 

What happens this time? I won’t keep you in suspense like last time:

Screen Shot 2018-09-18 at 9.12.10 PM

 

And there you have it.

Advertisements
Variables inside JavaScript Functions

Repairing Doc Martens soles, Pt 1

I didn’t think about making this a blog post before I started, so I “apologize” for not having before photos.

Here’s the story: I purchased a pair of 1461 Smooth shoes from the Doc Marten’s store in Seattle WA in 2016. NB: these are not “Made in England” and are not subject to their “For Life” guarantee, which they discontinued on April 1, 2018 [I wonder why…] These were assembled in Vietnam, though my previous Made in China 1461s (not purchased at a Doc Martens store) fell apart almost immediately and the sole was garbage).

I intended for these to develop some character, wear lines, scuffs, etc. which isn’t something I typically allow for my shoes. But I like Docs that look like they have a story, and I still intended to keep them cleaned (saddle soap) and black (Lincoln polish). It didn’t take long for that to come to an end as I realized one slightly-wet day that the sole had released from the welt and water was getting in. I figured that was more-or-less OK because I have stuff to fix shoes. The internet had some ideas but no one offered ideas that seemed like they actually knew; lots of anecdotal “evidence”. I decided to try my standbys.

What didn’t work: I scrubbed out the seam with an emery board then rubbing alcohol. First I tried Shoe-Goo, which I’ve had good luck with. Nope. I cleaned the opening again and tried E-6000. Still nothing. I even tried PVC cement (because Doc’s soles are reportedly a PVC material) and I might as well have done nothing.

So they became shoes for dry days only. Which means they were forgotten for several months and didn’t get into regular rotation. I’ve worn them for less than 30 total days, and almost all of those days have been dry.

Today I decided I needed to try to repair them. I went back to the internet and the advice was “if you don’t have a hot knife to weld the rubber sole and welt, they’ll never stick together.” Well I am a blacksmith so this is right up my alley. The photo shows all of the equipment I used: a MAPP torch (propane would be fine), a hacksaw blade and my trusty bathroom fan that I use to vent fumes away from me toward the open door.

CAUTION: This process involves burning plastic. There will be lots of smoke and it smells dangerous. You must have good ventilation. Ideally you will have a fan to pull the fumes away from you, and a place like a garage or shed where people can be out of the building while it degasses.

20180902_144750

The process is simple: clean the opening and gently try to pull it open wider. If the seam is weak, now’s the time to figure that out. My sole was detached almost the entire length of the instep. Use your non-dominant hand to open the seam (I put my thumb against the shoe and used my fingers to spread the seam).

Light the torch, heat the blade and insert it in one end of the seam. Let the seam slightly close around the blade. Pull the blade an inch or so along the opening. Remove the blade then pinch the seam closed. Repeat. Do this quickly and fearlessly – a little finger skin is a small price to pay for functional shoes! (Kidding, you do have to work quickly but be safe about it. I don’t think gloves will help here because this requires a fair amount of dexterity). I kept a wood block handy to rest the blade and to scrape off the rubber as it built up.

The end result is not quite a thing of beauty and I haven’t had a chance to wear them. I promised my girlfriend I would throw them away then had a change of heart because that’s super wasteful- look at these things! They look good from above, but the sides are a bit of a mess (the sole did not tear cleanly away from the welt, so that didn’t help the overall aesthetic). However, when I try to pull the seam apart it feels firmly stuck. I will update this when it rains and let you all know how well this worked.

20180902_15042320180902_150453

Repairing Doc Martens soles, Pt 1