Today in therapy, we talked about mindfulness. That is my homework. To try being mindfull about something and write about my experience. Why do I feel that I’m going to fail this? My mind can be quite sarcastic and sometimes judgemental. Mindfulness is a type of meditation where you become acutely aware of what you are feeling and sensing without being judgemental about it. Things like exercising and reading are coping mechanisms and not really getting to the root of anxiety. I’m having anxiety about meditation. Will it make me sleepy? Will my mind just wander? The purpose of Mindfulness Meditation in counseling (as opposed to other forms and intentions of meditative practices) is NOT to become calm! The purpose is to notice when our minds have wandered off and to be able to return our attention to the Present Moment, using our breath as an anchor. Allowing our minds to wander to our pasts often results in negative thought spirals. But wouldn’t meditation calm me? I thought that was the purpose of meditation.
I will come back to this with some thoughts and results of me trying to do mindfulness meditation.
First, I must go exercise as I told myself 5pm and it is 4:54.
And another thing. Sometimes the notes for JavaScript can be so obvious that I can do the problem cause it’s obvious how to do it that I get the problem correct even though I still don’t understand what I just did. Does anyone have that problem when learning?
JavaScript notes…
——————————————-
Up until now you have been adding properties to the prototype individually:
Bird.prototype.numLegs = 2;
This becomes tedious after more than a few properties.
Bird.prototype.eat = function() { console.log("nom nom nom"); } Bird.prototype.describe = function() { console.log("My name is " + this.name); }
A more efficient way is to set the prototype to a new object that already contains the properties. This way, the properties are added all at once:
Bird.prototype = { numLegs: 2, eat: function() { console.log("nom nom nom"); }, describe: function() { console.log("My name is " + this.name); } };
Add the property numLegs and the two methods eat() and describe() to the prototype of Dog by setting the prototype to a new object.
function Dog(name) { this.name = name; } Dog.prototype = { // Only change code below this line };
function Dog(name) { this.name = name; } Dog.prototype = { // Only change code below this line numLegs: 4, eat: function() { console.log("nom nom nom"); }, describe: function() { console.log("My name is" + this.name); } };
There is one crucial side effect of manually setting the prototype to a new object. It erases the constructor property! This property can be used to check which constructor function created the instance, but since the property has been overwritten, it now gives false results:
duck.constructor === Bird; duck.constructor === Object; duck instanceof Bird;
In order, these expressions would evaluate to false, true, and true.
To fix this, whenever a prototype is manually set to a new object, remember to define the constructor property:
Bird.prototype = { constructor: Bird, numLegs: 2, eat: function() { console.log("nom nom nom"); }, describe: function() { console.log("My name is " + this.name); } };
Define the constructor property on the Dog prototype.
function Dog(name) { this.name = name; } // Only change code below this line Dog.prototype = { numLegs: 4, eat: function() { console.log("nom nom nom"); }, describe: function() { console.log("My name is " + this.name); } };
function Dog(name) { this.name = name; } // Only change code below this line Dog.prototype = { constructor: Dog, numLegs: 4, eat: function() { console.log("nom nom nom"); }, describe: function() { console.log("My name is " + this.name); } };