ICT

Subdecks (1)

Cards (82)

  • Variable
    A value that can change, depending on conditions or on information passed to the program
  • Ways to declare a JavaScript variable
    • Using var
    • Using let
    • Using const
    • None
  • var keyword

    Used in all JavaScript code from 1995 to 2015, if you want your code to run in older browsers
  • let
    Variables defined with let can not be redeclared, must be declared before use, has a block scope
  • const
    Variables defined with const cannot be Redeclared, cannot be Reassigned, has a Block Scope
  • Variable identifier rules
    • All JavaScript variables must be identified with unique 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
    • Reserved words cannot be used as names
  • In JavaScript, there are 2 common types of data: Text values for "strings" and numbers
  • Manipulating numbers
    Display the sum of 2 numbers on the alert box using a button
  • JavaScript function

    A block of code designed to perform a particular task
  • JavaScript function definition

    • Defined with the function keyword, followed by a name, followed by parentheses ()
  • Parameters
    Listed inside the parentheses () in the function definition
  • Arguments
    The values received by the function when it is invoked
  • When a function can be invoked

    • When an event occurs
    • When it is invoked (called) from JavaScript code
    • Automatically (self invoked)
  • Return keyword
    Functions often compute a return value, which is "returned" back to the "caller"
  • Why use functions
    • To reuse the code
    • To avoid repetition of codes
    • To use the same code with different arguments for different outcomes
  • Single line- Starts with //.
  • Multi-line - start with /* and end with */
  • JavaScript Variables
    A variable is a value that can change, depending on conditions or on information passed to the program
  • Variable rule for identifier
    • Names can contain letters, digits, underscores, and dollar signs.
    • Names must begin with a letter
  • Variable rule for identifier
    • Names can also begin with $ and _
    • Names are case sensitive
    • Reserved words cannot be used as names
  • Return keyword

    Functions often compute a return value. The return value is "returned" back to the "caller"
  • JavaScript

    The programming language of the webpage
  • JavaScript
    • Cross-platform
    • Object-oriented
    • Scripting language
    • Developed by Netscape
    • Created by Brendan Eich
  • JavaScript is designed for use on web pages and closely integrated with HTML
  • JavaScript can create applications which run in the browsers
  • JavaScript was first released under the name of LiveScript as part of Netscape Navigator 2.0
    September 1995
  • JavaScript was renamed from LiveScript
    December 4, 1995
  • JavaScript
    • Free for everyone
    • Easy to use
    • Can be used on browser, laptop/PC, tablet, and smartphones
  • 3 languages all web developers must learn
    • HTML to define the content of web pages
    • CSS to specify the layout of web pages
    • JavaScript to program the behavior of web pages
  • Why study JavaScript?
    JavaScript can change HTML content, change HTML attribute values, change HTML styles (CSS), hide HTML elements, show HTML elements
  • Where to code JavaScript
    1. Scripts/Codes in JS can be inserted inline with HTML codes
    2. Script can be placed in the <body>, or in the <head> section of an HTML page, or in both
    3. Scripts can also be placed in external files
  • Advantage of separating scripts from HTML file
  • No, we don't need script tags in external JS file
  • 4 display possibilities in JavaScript
    • Writing into an HTML element, using innerHTML
    • Writing into the HTML output using document.write()
    • Writing into an alert box, using window.alert()
    • Writing into the browser console, using console.log()
  • To access the HTML element
    1. Use the document.getElementById() method
    2. The innerHTML property defines the HTML content
    3. The style property, followed by CSS property, defines the design or layout of the element
  • document.write()
    • Use for testing a code
    • Using document.write() after an HTML document is loaded, will delete all existing HTML
  • window.alert()
    Use to display data using alert box
  • console.log()
    Use for debugging purposes, to display data in the browser console
  • window.print()
    Use to access the external device (printer) for printing purposes
  • Formative Assessment: Change HTML Content, Change HTML Attribute Values, Change HTML Styles (CSS), Hide HTML Elements, Show HTML Elements