Introduction Flashcards
How does Javascript makes web pages more interactive?
- Access Content: You can use javascript to select any element, attribute, or text from an html page. e.g. Select the text inside all of the <h1> element on a page
- Modify Content: You can use javascript to add elements, attributes, and text to the page, or remove them. e.g. Add a paragraph of text after the first <h1> element
- Program Rules: you can specify a set of steps for the browser to follow which allows it to access or change the content of a page i.e. a gallery script could check which image a user clicked on and display a larger version of that image
- React to Events: You can specify that a script should run when a specific event has occurred. e.g. a button is pressed, a link is clicked, etc.</h1></h1>
What does Javascript do?
It allows you to make web pages more interactive by accessing & modifying the content and markup used in a web page while it is being viewed in the browser.
What are some examples of javascript at work?
Slide Shows: Can display a # of different images within the same space on a given page. They can play automatically as a sequence, or users can click through the slides manually
Forms: Validating forms when info is entered by users - allows you to alert users if a mistake has been made - can also perform calculations on any data entered
Reload Part of A Page: when refreshing the entire page isn’t necessary and only a portion of the page needs to be refreshed to make the site feel faster
Filtering Data: When you’ve got a lot of info. to display on a page, you can help users find information they need by providing filters.
What are scripts?
A script is a series of instructions that a computer can follow step-by-step. A browser may use different parts of the script depending on how the user interacts with the web page. Scripts can run different sections of the code in response to the situation around them.
What are the steps to writing a script
- Define the goal: First, you need to define the task you want to achieve. Think of it as a puzzle you want the computer to solve
- Design the script: split the goal out into a series of tasks that are going to be involved in solving this puzzle - you can use a flowchart.
write down the individual steps to complete each individual task (and any info it needs to perform the task), rather like writing a recipe that it can follow
3. Code each step - Each of the steps needs to be written in a programming language that the computer understands
What are objects?
In computer programming, each physical thing in the world can be represented as an object.
What are some of the things that each object will have in the computer programming world
- Properties
- Events
- Methods
What are properties?
Characteristics of the object. Each property has a name & value, and each name/value pair tells you something about each individual instance of the object
What are events?
Programs are designed to do different things when users interact with the computer in different ways. An event is the computers way of sticking up it’s hand to say “hey, this just happened”. Scripts use different events to trigger different types of functionality - a script will state which events the program wants to respond to, and what part of the script should be run when each of those events occur.
What are methods?
Methods represent things people need to do with objects. They can retrieve or update the values of an objects properties. They represent how people interact w/ an object in the real world. They’re like questions/instructions that tell you something about that object (using info. stored in its properties), or Change the value of one or more of that object’s properties.
What does a method do?
The code for a method can contain lots of instructions that together represent one task
how do events, methods, and properties relate?
events can trigger methods, and methods can retrieve or update an object’s properties
What are web browsers built out of?
Objects - web browsers create similar models of the web page they’re showing and of the browser window that the page is being shown in.
What does the document object represent?
an html page. Like other objects that represent real-world things, the document object has properties (characteristics of the current web page), methods (perform tasks associated with the document currently loaded in the browser), events (you can respond to events, such as a user clicking or tapping on an element)
How do browsers interpret the html code & applies styling to it.
- Receive a page as html code
- Create a model of the page and store it in memory
- Use a rendering engine to show the page on screen