What is the significance of faded properties when using console.dir in Chrome Developer Tools Console

Faded properties apper to indicate non-enumerable properties. If we do: var a = {}; Object.defineProperties(a, { hello: { enumerable: false }, world: { enumerable: true } }); console.dir(a); then we see that hello is faded, while world is not. In your code, if you do for(prop in obj) { console.log(prop); } (where obj is whatever … Read more

Java object destructuring

Java Language Architect Brian Goetz has recently talked about adding destructuring to an upcoming version of Java. Look for the Sidebar: pattern matching chapter in his paper: Towards Better Serialization I strongly dislike the current proposal of the syntax, but according to Brian your use case will look like the following (please note, that at … Read more

Getting container/parent object from within python

Pass a reference to the Bar object, like so: class Foo(object): def __init__(self): self.text = “Hello World” # has to be created first, so Bar.__init__ can reference it self.bar = Bar(self) class Bar(object): def __init__(self, parent): self.parent = parent self.newText = parent.text foo = Foo() Edit: as pointed out by @thomleo, this can cause problems … Read more

Arrays in type script

This is a very c# type of code: var bks: Book[] = new Book[2]; In Javascript / Typescript you don’t allocate memory up front like that, and that means something completely different. This is how you would do what you want to do: var bks: Book[] = []; bks.push(new Book()); bks[0].Author = “vamsee”; bks[0].BookId = … Read more