<?php
// Include the config file first
include_once("../includes/config.inc.php");

// Set the page variables
$page_title = "This Keyword";
$page_description = "A brief post about what the this keyword is and how it is used";
$page_author = "Peter K";

// Then include the header (it will use the page variables above)
include_once("../includes/header.inc.php");
?>

	    	<!-- Beginning of blog post -->
	    	<div class="blog-post">
	    		<h2 class="blog-post-title">"this" Keyword</h2>
	    	  	<p class="blog-post-meta">Sept 17, 2020 by Peter Ketter</p>

	    	  	<p>A brief post about what the this keyword is and how it is used</p>
	    	  	<hr>
	    	  	<h3>What is "this"</h3>
	    	  	<p>
					The keyword “this” refers to the object it belongs to.
					That is the general definition of the “this” keyword, 
					but what does that mean when looking at the actual use while programming. 
					When used inside of a method, “this” refers to the object it is showing up
					in.  
	    	  	</p>
	    	  
	    	  	<p>
					A code example of this would be as follows:
	    	  	</p>
	    	  	<pre class="language-js"><code>var dog = {
	firstName : “Watson”,
	middleName : “Charles”,
	breed : “English Bulldog”,
	markings : “red, white and brindle”,
	fullDescription : function() {
		return this.firstName + “ “ + this.middleName + “ is a “ + this.breed;
	}
};</code></pre>
	    	  	<h3>"this" as a global keyword</h3>
	    	  	<p>
					When “this” is used alone or in a function it refers
					to the global object. Now this means that it changes
					slightly depending on what the global object is, but
					when talking in terms of JavaScript the global object.
					The reason that “this” refers to the global object
					within a function is because a function does not belong
					to a more specific object like a method does. What this
					means, is if we were to consoleLog(this) we should get
					the window object.   	  
				</p>
				<pre class="language-js"><code>var x = this;
consoleLog(this);</code></pre>

</div>
<!-- End of blog post -->
<?php