Best VPN Service (English Banners)

Javascript Basics

Alibaba Cloud
Autonomous Standing Desk

System Mechanic® Ultimate Defense™
Save up to 50% on ANSI Standards Packages

notes from 2015


is an object-oriented computer programming language commonly used to create interactive effects within web browers.

IK Multimedia's T-RackS 5

document.write(“Hello from Javascript”);


is a storage location paired with an associated symbolic name (an identifier), which contains some known or unknown quatity of information referred to as a value.

is a stored piece of information (stored data) that can be changed.

Autonomous Standing Desk
  • Named Container for Storing Values
  • Can be set to anything
  • Declared using the var keyword

must start your variable with letters or “_”
== is exact comparison
!== not the same
=== is strict comparison

// var myNumber = 42;
// document.write(myNumber);
// var myString = “This is a string392r23f*()))88”;
// document.write(myString);
// var myBool = false;
// document.write(myBool);
var myNumber = 42;
myNumber = myNumber + 10;
var myBool = 42 == 56
var myVar
var myExample = “42”;
document.write(myExample === 42);
// var paragraph = document.getElementById(“par2”).innerHTML;
// document.write(paragraph);


is a piece of  data with predefined characteristics.

Q: On what datatype in Javascript can calculations be done?
A: The “number” datatype. [p.s. integer does not exist in javascript]


Modifying HTML Content

Q: What property of the full mark up of an element is used to get its contents?
A: The “.innerHTML” property

  • document.getElementsByTagName(‘p’);
  • document.getElementById(‘par2’); from <p id=”par2″>paragragh2</p>

document.getElementById(‘par2’).innerHTML = “Loading Amendments…”


(or method) is a prewritten set of instructions that may or may not return a value.

Q: What keyword is used in Javascript to designate the creation of a function?
A: The “function” keyword.

  • Block of code designed to perform a particular task
  • Only runs when called
  • Declared using the function keyword



// myFunc();
// myFunc();myFunc();myFunc();
// myFunc();
// function myFunc(){
// document.write(“myFunc() was called”)
// }
// myFunc();
// function myFunc(){
// document.getElementById(‘par2’).innerHTML = “This was changed by a function”;
// }
myFunc(“This is a dynamic argument!”);
function myFunc(input){
document.getElementById(‘par2’).innerHTML = input;


“Javascript Widgets”

• What is a Server?
• Web Hosting Services
• Introduction to XAMPP
• Putting Content Online


Programming Fundamentals
• Getting our web application to “think”
• Conditional logic, loops, and arrays

– Deductive Reasoning:

Q: If a card has a vowel on one side, it must have an even number on the other side

A.   K.   2.   7.

A: Should be A and 7. (May be adding K as well, as you want to make sure the other side of K is not an even number.)

Which card(s) must be turned over to determine whether or not the rule has been followed?

Conditional Statement: is a if-then statement in which a hypothesis is followed by a conclusion.

The ‘if’ Statement


  • Found in every piece of software
  • Found in every web application
  • Simplest and most popular method to create conditional statements in programming
if (/*condition* */) {
       //Execute this code
(L5 ppt)
  • Checks if the condition, or hypothesis, is met
  • Executes some code, or conclusion


The ‘else’ Statement


• Used at the end of an ‘if’statement

• Executes code when the ‘if’condition is not met



Array is a special variable in Javascript (and other programming languages) that can hold multshaw-web-dev-2019-l5-2.pngiple values at the same time.

var arrayName = [item1, item2, …];





Loop is a programming construct which allows one or more statements to be repeatedly executed a desired number of times.

For Loop

Executes a block of code a number of times.
for(statement 1; statement 2; statement 3){
            // Code to be executed
for( i = 0; i < 5; i++) {
    // Code to be executed
var animals = [‘cat’,’spider’,’dog’,’diraffe’,’elephant’,’whelk’,’parrot’,’peacocks’,’zebras’];
// document.write(animals[2].length);

// for( i = 0; i

for( i = 0; i

document.write(“====The for loop has executed=====


document.write(“This is the “+i+”th run of the loop


document.write(“The element in the animals array is ” +animals[i]+”