browse by category or date

I recently picked up a book at Singapore’s National Library. The title is Expert JavaScript.

The book starts with a chapter explaining about the concept of object in JavaScript. The opening chapter really blows my mind. Below code is familiar to me:

//create object
var animal = {};

//define property
animal.legs = 4;

But I don’t know that I can configure the properties as below:

var animal= {};
 
Object.defineProperty(animal, 'legs', {
  writable: true,
  configurable: true,
  enumerable: true,
  value: 4
});
 
Object.defineProperty(animal, 'ears', {
  writable: true,
  configurable: true,
  enumerable: true,
  value: 2
});
 
Object.defineProperty(animal, 'secretTrackerEnabled', {
  enumerable: false,
  value: true
}); 

for (var x in animal) {
  console.log(x);
}

// => legs
// => ears
 

Seriously, this book is really good. It only only took me one chapter to realize how I have missed so much of JavaScript’s core concept.

GD Star Rating
loading...
Book Review: Expert JavaScript by Mark Daggett, 4.0 out of 5 based on 1 rating

Possibly relevant:

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Incoming Search

javascript

No Comment

Add Your Comment