I love JavaScript, however very often, it doesn’t love me back.
const dataBuffers = new Array(4); dataBuffers.fill([]); for (let i = 0; i < 4; i += 1) { dataBuffers[i].push(7); } console.log(JSON.stringify(dataBuffers)); // guess what is the answer? If you guess the answer would be [[7],[7],[7],[7]], then think again.
The problem is that dataBuffers.fill([]) will create you a single array, and fills the dataBuffers with the reference of the array. It is actually pretty clear if you have done JavaScript or any language long enough, but one might be stuck with the impression that the dataBuffers is filled with an empty array.
Recently, I switched to the Ghost blogging platform. I must say that it’s actually quite nice. Well, it’s still young, and some stuff needs to be taken care of. You need to use “forever” or an init.d script and monitoring to make sure it will stay running. You have to take care of setting up the mail service because it still can’t do it automatically like other platform, etc, etc. Well, you can also pay them to host it for you and forgot all those stuffs though.
One of the mistake which I see often during development on the frontend side is the cancel button, which actually submits the form when clicked. Saw it once, wait a while, saw it again, wait a while, saw it again, and the loop continues. Some people doesn’t even realize.
So what’s the problem? Let’s take a look at a normal html form in AngularJS. HTML Code
<div ng-app="MyApp"> <div ng-controller="MyController"> <form ng-submit="submitTheForm()"> <div class="form-group"> <label for="name">Name</label> <input type="text" class="form-control" ng-model="someone.
So one day, out of the blue, my grunt build job started failing in jenkins. I was quite confused why. Because it was working fine if I did it from my dev machine. I have a PC, a personal laptop, a work laptop, and two home servers (which are just old laptops converted to do various stuffs), and it worked fine in all, except in one of the home server which is running jenkins.
So I was working on a private project with angular js and video js, and I am loading videojs dynamically after I got the source of the video, and there’s this very interesting problem where videojs will only be loaded only if you hard-refresh the page (f5-button). If you navigate to the page where it contains the video, or if you were on the page, go somewhere else, then come back again, the video won’t be loaded anymore and you’ll only get your old html5 video from the browser.