JavaScipt and Intelligent Code

JavaScript is the most popular programming langauge in the world today. It is also built into every web browser. To take full advantage of HTML5, CSS3, and the web browsers capabilities, you need to learn at least basic JavaScript. JavaScript is built into every modern web browser in the world, that includes Chrome, Firefox, Internet Explorer, Safari etc… THAT IS AMAZING!!! You will also find JavaScript on every type of computer Windows, Mac, Linux you will also find it on IOS-iPads, iPhones, and Android. JavaScript is a very important langauge to learn especially if you want to get into web-design and web-app creation. All modern websites and web apps use JavaScript. There is a JavaScript app built into every web browser, it is there to process all of the JS code that you will be writing as a web-designer/developer, JS is short for JavaScript so from now on if you see JS you know what it stands for. Computer languages are just instructions for your computer to follow/execute… HTML for instance is designed to tell web-browsers what to put in a webpage. JavaScript on the other hand is a true programming language it allows you to give websites decision making capabilities. AWESOME INTELLIGENT CODE!!! THAT CAN MAKE DECISIONS… It can be easy disicions such as checking to see if someone put in an email address properly to very advanced programming where you can set up a whole game.

I found the light bulbs on W3Schools.com it is an awesome website full of information and learning material for everything webdevelopment. The Script below when written into the proper code editor I use Visual Studio Code for almost all of my projects now. I started with Sublime Text and also Atom these are all great code editor but I stick with VS Code Editor it is just my favorite you may choose to download and use Atom either way pick one that helps with color coding and code completion.

<!DOCTYPE html>
<html>
  <body>
    <h2>What Can JavaScript Do?</h2>

    <p>JavaScript can change HTML attribute values.</p>

    <p>
      In this case JavaScript changes the value of the src (source) attribute of
      an image.
    </p>

    <button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">
      Turn on the light
    </button>

    <img id="myImage" src="pic_bulboff.gif" style="width: 100px" />

    <button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">
      Turn off the light
    </button>
  </body>
</html>

JavaScript Variable

Variables: are virtual containers for informaiton – Rules for Variable names: Names can contain Letters, digits, underscores, and dollar signs. Names must begin with a letter. Names can also begin with $ and _ … Names are case sensitive (y and Y are different variables) Reserved words (like JavaScript keywords) cannot be used as names.

Variable Declaration

var name = ‘Shad’; Strings can be double quotes or single. Now we can console log this variable or we could create an alert. We will show both examples. A declaration is a statement in which a VALUE IS ASSIGNED TO A VARIABLE.

var firstName; = A declaration is a statement in which a value is assigned to a variable. firstName = ‘Shad’; = This is giving the variable a value, then you can console it out like this or alert it out into a dialog box . alert(firstName); console.log(firstName); Which will give you Shad in this case.

Variable’s can be Reassigned

var name = ‘John Doe’; console.log(name); And you will Get ‘John Doe’; name = ‘Steve Smith’; console.log(name); You can reassign variable if you use Var or Let….

Initialize Variable

var greeting; //Init var = set to undefined not assigned to a value or set equal to anything. So if console.log(greeting); you will get undefined…But we can take this variable now and set it to something by taking greeting = ‘Hello’; Now if you console.log(greeting); We will get Hello…Alot of times you will do this if you have a conditional as an if statement which we will talk about shortly…So if greeting equals this or else greeting equals that…

Variables: virtual containers for information

There are three possible keywords to define a variable. ‘var’, which has been around since the beginning of JavaScript we also have ‘let’, and ‘const’ which was introduced in (ES6) which was an update to JS which included many new features. “let and const are now fully supported in the browser” Var, and Let, both can be reassassigned.

Primitive Data Types:

Stored directly in the location the variables accesses

Stored on the Stack

Six Primitive Data Types:

  • String
  • Number
  • Boolean
  • Null
  • Undefined
  • Symbols (ES6)

Reference Data Types / Objects:

  • Arrays
  • Object Literals
  • Functions
  • Dates
  • Anything Else…

Primitive

String

const name = 'John Doe';

Leave a Reply

Your email address will not be published. Required fields are marked *