Difference between revisions of "Javascript"

From Publication Station
Line 43: Line 43:
* Object: HOW TO BEST DESCRIBE IT
* Object: HOW TO BEST DESCRIBE IT
** <code>var saturn = {"moons": ["Pan", "Daphnis", " Atlas", "Prometheus", "Pandora"], "Volume":"95.159 Earths"}</code>
** <code>var saturn = {"moons": ["Pan", "Daphnis", " Atlas", "Prometheus", "Pandora"], "Volume":"95.159 Earths"}</code>


{{#widget:Iframe
{{#widget:Iframe
|url=https://codepen.io/PublicationStation/pen/ZxvwpW/
|url=https://www.semantic-mediawiki.org/w/images/8/80/20171004_Beginners_tutorial_to_Semantic_MediaWiki.pdf
|width=410
|height=342
|border=0
}}
}}


<p data-height="265" data-theme-id="0" data-slug-hash="ZxvwpW" data-default-tab="js,result" data-user="PublicationStation" data-embed-version="2" data-pen-title="JS:variables2" class="codepen">See the Pen <a href="https://codepen.io/PublicationStation/pen/ZxvwpW/">JS:variables2</a> by Publication Station (<a href="https://codepen.io/PublicationStation">@PublicationStation</a>) on <a href="https://codepen.io">CodePen</a>.</p>
<p data-height="265" data-theme-id="0" data-slug-hash="ZxvwpW" data-default-tab="js,result" data-user="PublicationStation" data-embed-version="2" data-pen-title="JS:variables2" class="codepen">See the Pen <a href="https://codepen.io/PublicationStation/pen/ZxvwpW/">JS:variables2</a> by Publication Station (<a href="https://codepen.io/PublicationStation">@PublicationStation</a>) on <a href="https://codepen.io">CodePen</a>.</p>

Revision as of 17:27, 1 April 2018

Overview:

2 sessions

Subjects:

  • JS in webpages
  • JS data types & variables
  • loops
  • control structure
  • functions

What is JavaScript?

JavaScript is a scripting or programming language that allows you to implement complex things on web pages — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. — you can bet that JavaScript is probably involved.[1] </blockque>

Variables

https://codepen.io/PublicationStation/pen/wmpRyX

A variable is a container for some value. Like a number to be used in a sum, or a text string.

Most importantly: variables' values can change. They aren't the values themselves, but containers for values, like little boxes that you can store things in.


https://mdn.mozillademos.org/files/13506/boxes.png [2]


In order to use variables, we need to:

  • declare the variables
  • values can be attached to them

https://codepen.io/PublicationStation/pen/ZxvwpW


Data types

JS features a few data types, or in other words different types of content, which can be used as values of a variable. These include:

  • strings: pieces of text, always wrapped in single or double quotation marks var name = "I am Pluto";
  • numbers (both integers and float point numbers) var discovered = 1930;
  • booleans: true or false values (outside quotation mais) var planet = false; var dwarf=true;
  • Arrays (or lists): a container of multiple values enclosed in square brackets and separated by commas var planets=["Pluto", "Neptune", "Uranus", "Saturn"]
    • the values of arrays can be accessed by their location within the array var p=planets[0]; var s=planets[3]
  • Object: HOW TO BEST DESCRIBE IT
    • var saturn = {"moons": ["Pan", "Daphnis", " Atlas", "Prometheus", "Pandora"], "Volume":"95.159 Earths"}

{{#widget:Iframe |url=https://www.semantic-mediawiki.org/w/images/8/80/20171004_Beginners_tutorial_to_Semantic_MediaWiki.pdf |width=410 |height=342 |border=0 }}

See the Pen <a href="https://codepen.io/PublicationStation/pen/ZxvwpW/">JS:variables2</a> by Publication Station (<a href="https://codepen.io/PublicationStation">@PublicationStation</a>) on <a href="https://codepen.io">CodePen</a>.

<script async src="https://static.codepen.io/assets/embed/ei.js"></script>

References

  1. "What is JavaScript?" MDN Web Docs, 28 Mar. 2018, https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript.
  2. "Storing the information you need — Variables." MDN Web Docs, 28 Mar. 2018, developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Variables.