Latest Posts
Tuesday, November 30, 2021
Since JavaScript functions are objects they can have properties that belongs to the function itself. For example this simple example counts the number of times the function is being called by incrementing the counter property that belongs to the function.
<script> functionCount.counter = 0; function functionCount() { return functionCount.counter++; } for (var i = 0; i < 10; i++) functionCount(); console.log(functionCount.counter); </script>
Monday, November 29, 2021
When you define an object as an Array in JavaScript you get the benefits of inheriting some useful methods with it. Some of the common methods are those that allows you to add and delete elements from an array. The .push() method adds an element at the end of the array, the unshift() method adds an element at the beginning of the array. The delete keyword deletes an element at the specified index.
Let say you have an the following array:
var numbers = [3,4];
If you output the array in the browser console you will see that the array has two elements with the number 3 occupying index 0 and the number 4 occupying index 1.
Let say you have an the following array:
var numbers = [3,4];
If you output the array in the browser console you will see that the array has two elements with the number 3 occupying index 0 and the number 4 occupying index 1.
Friday, November 26, 2021
The switch statement is there to make the code more readable if the if statements contains too many branches and becomes too hard to read.
Consider the code below
var x = 6;
if (x === 1)
{
console.log("one");
}
else if (x === 2)
{
console.log("two");
}
else if (x === 3)
{
console.log("three");
}
else if (x === 4)
{
console.log("four");
}
else if (x === 5)
{
console.log("five");
}
else
{
console.log("x is not 1-5");
}
Consider the code below
var x = 6;
if (x === 1)
{
console.log("one");
}
else if (x === 2)
{
console.log("two");
}
else if (x === 3)
{
console.log("three");
}
else if (x === 4)
{
console.log("four");
}
else if (x === 5)
{
console.log("five");
}
else
{
console.log("x is not 1-5");
}
Thursday, November 25, 2021
Since an array is a collection of elements of objects, values, etc. The most common function performed on it is to iterate through each elements of the array. The most frequent way to do that is with a for loop.
Let's say you have an array with the following:
var numbers = ["one","two","three","four","five"];
The numbers array above contains five string elements, which also has a indexes associated with the it. There's also a length that is defined with each array that we will use for the for loop we are about to write. So what do the you length of the numbers array will be?
If we output the array to the browser with the statement console.log(numbers.length) do you think we will get the length to be 5 or 4?
If you guess 5 you are correct because there are five elements in the array. However, the arrays have zero based indexes therefore the index is always length -1
for(var i = 0; i < numbers.length; i++)
{
console.log(numbers[i]);
}
Let's say you have an array with the following:
var numbers = ["one","two","three","four","five"];
The numbers array above contains five string elements, which also has a indexes associated with the it. There's also a length that is defined with each array that we will use for the for loop we are about to write. So what do the you length of the numbers array will be?
If we output the array to the browser with the statement console.log(numbers.length) do you think we will get the length to be 5 or 4?
If you guess 5 you are correct because there are five elements in the array. However, the arrays have zero based indexes therefore the index is always length -1
for(var i = 0; i < numbers.length; i++)
{
console.log(numbers[i]);
}
Wednesday, November 24, 2021
JavaScript itself does not have multidimensional arrays, instead you can use an arrays of arrays instead. Multidimensional arrays are basically arrays that you can reference by rows and columns. The most obvious real world use is to store rows and columns of a database record. Imagine if you have a row of the database product from the database from the table "Products". Instead of storing each value in an individual variable you can store them in an arrays of arrays.
Let's say you have the following database Products table
Let's say you have the following database Products table
Tuesday, November 23, 2021
In the previous post we installed MongoDB on Linux on this post we are going to install MongoDB on Windows.
Here are the steps:
1. Go to https://www.mongodb.com/download-center/community, then click on the "Download" button
Here are the steps:
1. Go to https://www.mongodb.com/download-center/community, then click on the "Download" button
Monday, November 22, 2021
The Array.reverse() method reverses the order of the array elements. The easiest way to demonstrate this is to have an array with the numbers 1 to 5. If we call the Array.reverse() method we should get an array of 5 to 1. The Array.reverse() does not create a new array, it simply rearranges the array into a new order. Just keep that in mind when you are using this method.
So let's declare our array from 1 to 5
So if we call the numbers.reverse() method we should get an array of 5 to one in the reverse order
So let's declare our array from 1 to 5
<script> var numbers = [1, 2, 3, 4, 5]; </script>
So if we call the numbers.reverse() method we should get an array of 5 to one in the reverse order
Friday, November 19, 2021
The for loop is a looping construct in JavaScript that are more simplistic than the while loop. When writing the for loop there are three three parts they are
- Initialize - a count variable is initialize, it's usually zero but it doesn't have to be
- Test - A test to see if the loop should continue
- Increment - finally the count is incremented, it doesn't have to be an increment it could be decrements as well
Let's use the JavaScript code to demonstrate:
If you execute the loop below you will bet a for loop that executes when i is less than 10
for (var i = 0; i < 10; i++)
{
console.log("i is " + i);
}
console.log("i outside of for look is " + i);
Thursday, November 18, 2021
The forEach() method loops through an array, and performs a function on each element of the array. The forEach() method can take three arguments, the first argument is a current value that you want to perform an action on. The second argument acts as the "this" value within the scope of the function. The third argument is the array itself. Most of the time only the first argument is passed. The code below passes in only one argument which is an anonymous function being performed on each element of the array using the forEach() method to calculate the oil prices in the last five days and prints it out in the console.
<script> var oilPrices = [70.15, 69.50, 71.23, 74.32, 76.99]; var total = 0; oilPrices.forEach(function (value) { total += value }); console.log(total); </script>
Wednesday, November 17, 2021
In the previous post we created a load balancers with the target groups, rules, and instances to handle HTTPS traffic. In this post we are going to set up our DNS records in Route 53. So go to the Route 53 dashboard, click on your domain
1. Click on "Create record"
Subscribe to:
Posts (Atom)
Search This Blog
Tags
Web Development
Linux
Javascript
DATA
CentOS
ASPNET
SQL Server
Cloud Computing
ASP.NET Core
ASP.NET MVC
SQL
Virtualization
AWS
Database
ADO.NET
AngularJS
C#
CSS
EC2
Iaas
System Administrator
Azure
Computer Programming
JQuery
Coding
ASP.NET MVC 5
Entity Framework Core
Web Design
Infrastructure
Networking
Visual Studio
Errors
T-SQL
Ubuntu
Stored Procedures
ACME Bank
Bootstrap
Computer Networking
Entity Framework
Load Balancer
MongoDB
NoSQL
Node.js
Oracle
VirtualBox
Container
Docker
Fedora
Java
Source Control
git
ExpressJS
MySQL
NuGet
Blogger
Blogging
Bower.js
Data Science
JSON
JavaEE
Web Api
DBMS
DevOps
HTML5
MVC
SPA
Storage
github
AJAX
Big Data
Design Pattern
Eclipse IDE
Elastic IP
GIMP
Graphics Design
Heroku
Linux Mint
Postman
R
SSL
Security
Visual Studio Code
ASP.NET MVC 4
CLI
Linux Commands
Powershell
Python
Server
Software Development
Subnets
Telerik
VPC
Windows Server 2016
angular-seed
font-awesome
log4net
servlets
tomcat
AWS CloudWatch
Active Directory
Angular
Blockchain
Collections
Compatibility
Cryptocurrency
DIgital Life
DNS
Downloads
Google Blogger
Google Chrome
Google Fonts
Hadoop
IAM
KnockoutJS
LINQ
Linux Performance
Logging
Mobile-First
Open Source
Prototype
R Programming
Responsive
Route 53
S3
SELinux
Software
Unix
View
Web Forms
WildFly
XML
cshtml
githu