operation overload

3

#DDAY70 D-Day -3:

“Some of the eleven thousand planes that opened the path through the so-called impregnable Atlantic wall. Between Le Havre and Cherbourg in Normandy the Allied lightning strikes. Communications necessary to the German defenses are blasted.”

From: Universal News Volume 17, Release 302, June 12, 1944

When Assignments Don’t Work in JavaScript

In JavaScript is possible that simple assignment statement will occassionally fail. This is not due to a bug, but has to do with a language feature here is an example of what this could look like:

obj.property1 = [];
obj.property2 = [];

obj.property1.push(1);
obj.property2.push(1);
// Uncaught TypeError: Cannot read property 'push' of undefined

If you look at this closely, it is saying that obj.property2 has no push property since it is undefined and not an array. Despite the previous lines code assigning it. Although this looks like a bug, it is actually because the assignment operation of obj.property2 was overridden and no assignment function was given in the place of the default one. Here is the earlier code

const obj = {
  property1: [{ id: 'object-1' }],
};

Object.defineProperties(obj, {
  property2: { get: getProperty2 },
});

function getProperty2() {
  return undefined;
};

In this case, the error would be pretty obvious. But sometimes the code to generate the object is very separated from the code to use or update an object. Some environments like Node.js will show a more obvious error around the assignment like TypeError: Cannot set property property2 of #<object> which has only a getter, but many still do not. So this is something to keep in mind. I personally prefer to avoid overwriting fundamental operations like assignment when possible to avoid confusiong errors like this.

Github Location: https://github.com/Jacob-Friesen/obscurejs/blob/master/2017/getterIssue.js

Apptober: The Third Day

I’ve got the Binary object more polished than it was yesterday. The following changes have been made:

  • Made the Binary values signed.
  • Added functions for concatenation, checking if a Binary object is negative, and converting a Binary value to an integer.
  • Added operators for >, <, ==, !=, and –
  • Updated some functions, like caching Binary value lengths to avoid multiple function calls and changing the iterative method used.
  • Fixed the + operator and updated for the signed values.
  • Added some exception throws in

Keep reading

You are about to embark upon the Great Crusade, toward which we have striven these many months. The eyes of the world are upon you. The hope and prayers of liberty-loving people everywhere march with you. In company with our brave Allies and brothers-in-arms on other Fronts, you will bring about the destruction of the German war machine, the elimination of Nazi tyranny over the oppressed peoples of Europe, and security for ourselves in a free world. Your task will not be an easy one. Your enemy is will trained, well equipped and battle-hardened. He will fight savagely…The tide has turned! The free men of the world are marching together to Victory! I have full confidence in your courage, devotion to duty and skill in battle. We will accept nothing less than full Victory! Good luck! And let us beseech the blessing of Almighty God upon this great and noble undertaking.
—  General Dwight D Eisenhower, letter to troops before Execution of Operation Overload, June 1944
Best Posts of 2016

Earlier this year I added a sidebar for the most popular posts. So below is a list of what I think are the 5 best posts that are not in that Sidebar (as of December 2016):

1. Generators and Async Operations in JavaScript The most major criticism of asynchronous code in JavaScript is that it requires workarounds and a bunch code management to keep it clean. This new feature greatly reduces all of that.

2. Validating Object Property Types Without Setters In JavaScript A more powerful version of operator overloads which is coming to JavaScript with the Proxy API. This is one example, but Proxy could be used to create entirely new JS-like langauges without even having to compile or eval any code.

3. Lazy Objects In JavaScript In JavaScript, it is possible to have self creating objects that store their own state using themselves. This is done by applying the concepts of Lazy Functions to objects.

4. Compose in JavaScript Simplify the sequence of functions by using a function that controls function flow. The compose function is implemented using itelf.

5. Pretty Printing In JavaScript A simple and powerful, but overlooked way of doing pretty printing (Very useful for quick debugging). Built directly into the language.


Best Posts Of 2015

3

#DDAY70 D-Day -1:

Convoys of troop transports, landing craft and their escort ships begin their trip across the English Channel for the Normandy Coast.

Excerpted from: “D-Day to D plus 3.“  From the series: Moving Images Relating to Military Activities, compiled 1947 - 1964. Record Group 111: Records of the Office of the Chief Signal Officer, 1860 - 1985

4

#DDAY70 D-Day -2:

“England, June 4th, 1944

The men of the armies marched towards the southern ports.

Equipment rolled down the roads.

Men and machines took their places in the waiting ships.

The men were British, American, Canadian–some of them veterans of Africa, Sicily and Italy. Some new to battle…”

Excerpted from: “D-Day to D plus 3.”  From the series: Moving Images Relating to Military Activities, compiled 1947 - 1964. Record Group 111: Records of the Office of the Chief Signal Officer, 1860 - 1985

4

#DDAY70 - D-Day:

“…other airborne troops in gliders and tow planes prepared to take off from Britain. One by one until planes lifted the heavily laden gliders into the sky…”

Excerpted from: “D-Day to D plus 3.”  From the series: Moving Images Relating to Military Activities, compiled 1947 - 1964. Record Group 111: Records of the Office of the Chief Signal Officer, 1860 - 1985

#DDAY70 D-Day -1:

“Luncheon is Served in the English Channel -
Come and get it boys, while the getting’s good. Crossing the English Channel aboard a Coast Guard "Elsie” (or LCI), American soldiers catch their K rations and celery soup from the top of a 20mm ready box. Ahead lies the coast of France, but for the moment chow is the important thing. You can't fight on a hollow stomach.“

Photograph of American Soldiers Crossing the English Channel aboard a Coast Guard "Elsie” (LCI). Local Identifier: 26-G-2403. From the series: Activities, Facilities, and Personalities, 1886 - 1967. Records of the U.S. Coast Guard, 1785 - 2005

youtube

#DDay70 D-Day -4:

THE EVE OF INVASION

Universal Newsreel, in full co-operation with the War Department, presents official pictures of the final military preparations for the launching of D-Day.

A host of nations engage in the huge task. The invasion, in truth, is a United Nation’s effort.

From: Universal News Volume 17, Release 300, June 6, 1944