Skip to the content.

Class 7 Reading Notes

Lecture Notes:

Programming Defintion: list of instructions

Unless modified, code is run form top to bottom so it si importabt to know how want it to run

To call a function, you type the function’s name followed by parentheses and a semicolon:

Today really highlighted the important of clearly defining a variable with robot demonstration.

Control Flow: Unless modified, code is run from top to bottom so it is important to know how you want it to run

Conditional statements, loops, events, and functions are used to modify the control flow.

If a function has variables, then it is only aailable inside to the function - it is local to the function

What is script?

The < script > HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.

From https://www.google.com/search?q=javascript+script&rlz=1C1CHBD_enUS906US906&oq=javascript+Script&aqs=chrome.0.0i512l5j69i60l3.6724j0j7&sourceid=chrome&ie=UTF-8

What is programming problem-solving?

Solving problems is the core of computer science. Programmers must first understand how a human solves a problem, then understand how to translate this “algorithm” into something a computer can do, and finally how to “write” the specific syntax (required by a computer) to get the job done. It is sometimes the case that a machine will solve a problem in a completely different way than a human.

From https://www.cs.utah.edu/~germain/PPS/Topics/problem_solving.html

Expression

Any unit of code that can be evaluated to a value is an expression . Since expressions produce values, they can appear anywhere in a program where JavaScript expects a value such as the arguments of a function invocation.

Operator

In JavaScript, an operator is a special symbol used to perform operations on operands (values and variables). For example, 2 + 3; // 5. Here + is an operator that performs addition, and 2 and 3 are operands.

From https://www.programiz.com/javascript/operators

Function

A JavaScript function is a block of code designed to perform a particular task. A JavaScript function is executed when “something” invokes it (calls it).

JavaScript Function Syntax

From https://www.w3schools.com/js/js_functions.asp

*### Function declaration The function declaration (function statement) defines a function with the specified parameters.

From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function

Call

The call() allows for a function/method belonging to one object to be assigned and called for a different object. call() provides a new value of this to the function/method. With call(), you can write a method once and then inherit it in another object, without having to rewrite the method for the new object.

From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call

Parameters

Arguments are Passed by Value

From https://www.w3schools.com/js/js_function_parameters.asp

Arguments

The Arguments Object JavaScript functions have a built-in object called the arguments object. The argument object contains an array of the arguments used when the function was called (invoked). This way you can simply use a function to find (for instance) the highest value in a list of numbers:

From https://www.w3schools.com/js/js_function_parameters.asp

Return value

Return values are just what they sound like — the values that a function returns when it has completed. You’ve already met return values a number of times, although you may not have thought about them explicitly.

From https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Return_values

Refactoring

Key Term! Refactoring—in JavaScript and other languages as well—is the process of changing a piece of code without altering how it works. In other words: you play around with the internal structure of a given function, class, module, etc., without changing the results it produces.

From https://www.testim.io/blog/javascript-refactoring-5-plays-to-improve-code-quality/

The practice of refactoring was popularized by the rise of the agile methodologies. Refactoring is, for instance, an important—and often overlooked—step in the TDD (test-driven development) cycle. Martin Fowler, who literally wrote the book on Refactoring, was one of the authors of the agile manifesto.