Concatenate an array in JavaScript

I’ve been slacking off on the food-related posts lately because of my day job. Then it occurred to me that I started this blog as a general repository of things that interest me, even non-food things. I read a recent article about how productive StackOverflow has made developers because they no longer have to RTFM. I know I have found a lot of value in googling bugs in my code.  In an effort to contribute to the interweb knowledge base, I’m going to try to post a couple of short blogs each week with tips I’ve learned while developing, no matter how elementary they could be.  Who knows, maybe someone else will save some time by stumbling on these posts.

Recently, I’ve been needing to concatenate arrays in JavaScript.  Using the concat() method is tricky because concatenating one array into the other creates a new array instead of altering the original array:

arr = [1,2,3]
>> [1, 2, 3]
arr2 = [4,5,6]
>> [4, 5, 6]
arr.concat(arr2)
>> [1, 2, 3, 4, 5, 6]
arr
>> [1, 2, 3]

 

The above isn’t exactly what I wanted, so I’ve been doing this instead, which lets me concat an array into the first array, altering the first array:

arr
>> [1, 2, 3]
arr2
>> [4, 5, 6]
Array.prototype.push.apply(arr, arr2)
>> 6
arr
>> [1, 2, 3, 4, 5, 6]

 

Breakfast Like a Shanghailander


sh_breakfast 6Step 1: Locate the breakfast spot, usually in a residential alley. Telltale signs are giant, bubbling pots, a charcoal oven with a huge bamboo steamer basket of rice over it, a precarious deep fryer with golden sticks of airy you tiao sticking out of the fry basket, and a counter dusted with flour.  We were lucky that the proprietors of our go-to spot was always shaping fresh dough for deep frying.
sh_breakfast 5Step 2: Order a piece of fried dough, most likely a you tiao and a bowl of savory soy milk.  I went to one place where the server gave me a bowl with all the savory toppings and some vinegar already in it. Then she fetched a steaming ladle full of fresh soy milk and poured it into the bowl so that the soy milk congealed on the spot.  Don’t forget to dip the you tiao into the soy milk.

sh_breakfast 3

Step 3: Also try out the fresh silken tofu. This is a more congealed form of the soy milk.  The savory toppings often contain green onion, pickled vegetables, tiny dried shrimp, and soy sauce.  You tiao also goes well in here if you tear it off into bite sized pieces to soak up the salty broth.

sh_breakfast 1Step 4: Order a rice hash brown (chi fan gao) for the road. It’s best to order this on your way out, because it is perfect straight out of the fryer. The outer layer of crunch is a perfect envelope to the sticky, dangerously hot rice packed in the middle.

 

Protip: If you’re vegetarian, you can order the savory items without the dried shrimp.

 

Jian Bing is a Don’t Miss Breakfast in Shanghai


Living in the SGV, with its dizzying selection of regional Chinese restaurants, has its benefits, but there are some things I still miss from Shanghai. One of these things is the jian bing, a savory egg crepe that’s best eaten seconds after it comes off a hot plate. I feared that the fast modernization of Shanghai which was quickly replacing the old style tenements with luxury apartments would be the death of street food like this. I was grateful that on my last trip to Shanghai, there was not only still jian bing to be had, but that it was only a block away from where I was staying.


The telltale sign of a jian bing vendor is a large, round hotplate. It’s something that can be spotted from far away. The small crowd of people waiting for their breakfast is also a good sign. For less than one US dollar, I got a crunchy, savory breakfast that I had been looking forward to for years.

The jian bing vendor, a woman with a friendly but no-nonsense face, was a seasoned pro — quickly manipulating a thin layer of batter onto the hot, coal-heated hotplate. While the wheat batter cooked to a crisp, she broke an egg over the top, quickly spread and scrambled the egg before it set, smeared on a sweet and salty bean paste, some thin, spiced potato strips, a sprinkling of cilantro, and then a deep fried wonton wrapper. With her hands and a spatula, she deftly turned up the edge of the crepe, rolling it over itself into a long tube. Then “crunch!” as she used the edge of the spatula to crease the middle of the crepe, folded it in half, placed it into a thin plastic bag before handing it to me. She told me to eat it on the spot, reminding me to bite through both halves in one go. Still steaming from the heat, and pungent from the spiced potatoes, it was a great start to the morning.

On subsequent mornings, it became fascinating to watch the different customizations of jian bing customers were getting. Some prefer the added crunch of adding a you tiao (fried crueller). While she has a handful of you tiao (for 1RMB) for those who prefer it, one can also walk across the alley, buy a freshly fried you tiao from another vendor, and bring it over. One customer who lived nearby brought her own egg, saying she had extra at home, and got a 1RMB discount on her jian bing. Another brought his own sausage to add inside. And another wanted a cucumber inside. The customization options are endless. The jian bing vendor also remembered the preferences of her more frequent customers: less sweet, or no cilantro, or extra egg.

When she was done making all the jian bing orders of the morning and the customers were gone, the vendor packed up her stuff to go off to her second job, cleaning the house of a tenant of one of the luxury apartments nearby.