October 20 2018

From Object Oriented JavaScript (Part the First) var literalDog = { // declaration AND instantiation name: "Vincent", // object property speak: function() { // object method return this.name + " says woof"; } }; literalDog.speak(); // "Vincent says woof" Inside of the speak method the this variable will refer to the current context of the function execution. This is an important distinction with classically object oriented languages: the value of this can (and often does) change! In most cases, this inside of a method like the one above will refer to the current object or instance. Without some other influence, if a method is called with “dot” syntax as in the last line above, then you can generally expect this inside the function to be whatever is on the left side of the dot. Inside of literalDog.speak() the this variable...

Continue Reading →

Unless otherwise mentioned in the post, those projects are side projects which I work on on weekends and evenings, and are not affiliated with my work or employer.

Tags: software engineering, javascript, personal development   |   Report a bug via Twitter

October 19 2018

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes http://crockford.com/javascript/prototypal.html http://javascript.info/class-patterns https://dmitripavlutin.com/gentle-explanation-of-this-in-javascript/ http://crockford.com/javascript/private.html https://www.gamedev.net/blogs/entry/2265481-oop-is-dead-long-live-oop/ function Runner(name) { console.log(this instanceof Rabbit); // => true this.name = name; } function Rabbit(name, countLegs) { console.log(this instanceof Rabbit); // => true // Indirect invocation. Call parent constructor. Runner.call(this, name); this.countLegs = countLegs; } var myRabbit = new Rabbit('White Rabbit', 4); myRabbit; // { name: 'White Rabbit', countLegs: 4 } function Vehicle(type, wheelsCount) { if (!(this instanceof Vehicle)) { throw Error('Error: Incorrect invocation'); } this.type = type; this.wheelsCount = wheelsCount; return this; } // Constructor invocation var car = new Vehicle('Car', 4); car.type // => 'Car' car.wheelsCount // => 4 car instanceof Vehicle // => true // Function invocation. Generates an error. var brokenCar = Vehicle('Broken Car', 3); function Foo () { console.log(this instanceof Foo); // => true this.property = 'Default Value'; } // Constructor invocation var fooInstance = new Foo();...

Continue Reading →

Unless otherwise mentioned in the post, those projects are side projects which I work on on weekends and evenings, and are not affiliated with my work or employer.

Tags: software engineering, personal development   |   Report a bug via Twitter

October 18 2018

Private Members in JavaScript Private members are made by the constructor. Ordinary vars and parameters of the constructor become the private members. They are attached to the object, but they are not accessible to the outside, nor are they accessible to the object’s own public methods. By convention, we make a private that variable. This is used to make the object available to the private methods. function someFunction(someParam) { var that = this; } Private methods cannot be called by public methods. To make private methods useful, we need to introduce a privileged method. A privileged method is able to access the private variables and methods, and is itself accessible to the public methods and the outside. It is possible to delete or replace a privileged method, but it is not possible to alter it, or to force it to...

Continue Reading →

Unless otherwise mentioned in the post, those projects are side projects which I work on on weekends and evenings, and are not affiliated with my work or employer.

Tags: software engineering, personal development   |   Report a bug via Twitter

Untitled

“If big tech companies are going to turn their back on the DoD, this country is going to be in trouble,” said Bezos on stage at the Wired25 conference in San Francisco on Monday. I can view this comment through my Canadian glasses =) Having worked in academia, private, and, now, government environments at various levels — I can definitely appreciate the intricacies that go behind the scenes. While we are different countries, we follow similar implementations of organizational structures. We most likely use similar enterprise hardware and software. I also assume that applications of these things are similar in US and Canada. I further assume that such organizations have similar goals (perhaps different strategies). So when I see something like the following It has already worked with the DoD and multiple law enforcement agencies have used its facial recognition...

Continue Reading →

Unless otherwise mentioned in the post, those projects are side projects which I work on on weekends and evenings, and are not affiliated with my work or employer.

Tags: software engineering, personal development   |   Report a bug via Twitter