Module 5: Getting Started with JavaScript Flashcards
It is lightweight and most commonly used as a part of web pages, whose implementations allow client-side script to interact with the user and make dynamic pages.
JavaScript
It is an interpreted programming language with object-oriented capabilities.
JavaScript
It is complimentary to and integrated with Java.
JavaScript
TRUE OR FALSE:
“JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform.”
TRUE
Is JavaScript a dynamic computer programming language?
Yes
JavaScript was first known as?
LiveScript
Why learn JavaScript?
- Most popular programming language in the world
- It is everywhere, comes installed on every modern web browser
- Helps you create really beautiful and crazy fast websites
- Its usage has now extended to mobile app development
- Tons of job growth and high pay for those who know JavaScript
- You can find tons of frameworks and libraries already developed
Applications of JavaScript Programming
- Client-side validation
- Manipulating HTML Pages
- User Notifications
- Back-end Data Loading
- Presentations
- Server Applications
This is really important to verify any user input before submitting it to the server and Javascript plays an important role in validting those inputs at front-end itself.
Client-side validation
This helps in adding and deleting any HTML tag very easily using javascript and modify your HTML to change its look and feel based on different devices and requirements.
Manipulating HTML Pages
You can use Javascript to raise dynamic pop-ups on the webpages to give different types of notifications to your website visitors.
User Notifications
Javascript provides Ajax library which helps in loading back-end data while you are doing some other processing. This really gives an amazing experience to your website visitors.
Back-end Data Loading
JavaScript also provides the facility of creating presentations which gives website look and feel. JavaScript provides RevealJS and BespokeJS libraries to build a web-based slide presentations.
Presentations
Node JS is built on Chrome’s Javascript runtime for building fast and scalable network applications. This is an event based library which helps in developing very sophisticated server applications including Web Servers.
Server Applications
the most common form of the language. The script should be included in or referenced by an HTML document for the code to be interpreted by the browser.
Client-side JavaScript
The JavaScript code is executed when the user submits the form, and only if all the entries are valid, they would be submitted to the Web Server.
Client-Side JavaScript
Can JavaScript be used to trap user-initiated events such as button clicks, link navigation, and other actions that the user initiates explicitly or implicitly?
Yes
Advantages of JavaScript
- Less server interaction
- Immediate feedback to the visitors
- Increased interactivity
- Richer interfaces
You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
Less server interaction
They don’t have to wait for a page reload to see if they have forgotten to enter something.
Immediate feedback to the visitors
You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
Increased interactivity
You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.
Richer interfaces
- Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reason.
- JavaScript cannot be used for networking applications because there is no such support available.
- JavaScript doesn’t have any multi-threading or multiprocessor capabilities.
Limitations of JavaScript
Javascript can be implemented within what HTML tags?
<script> tags </script>
2 important attributes of script tag
- Language
- Type
This attribute specifies what scripting language you are using. Typically, its value will be javascript. Although recent versions of HTML (and XHTML, its successor) have phased out the use of this attribute.
Language
This attribute is what is now recommended to indicate the scripting language in use and its value should be set to “text/javascript”.
Type
Does JavaScript ignore spaces, tabs, and newlines?
Yes
Semicolons in JavaScript are…
Optional
JavaScript is a ______________ language. This means that the language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
case-sensitive
Single line comment JavaScript
//
Multi-line comment in JavaScript
/* */
f you want to have a script run on some event, such as when a user clicks somewhere, where should you place the script?
In the <head> tags
If you need a script to run as the page loads so that the script generates content in the page, where should the script go?
In <body> portion of the document
Can JavaScript be kept in an external file?
Yes
These are the type of values that can be represented and manipulated in a programming language.
JS Datatypes
3 primitive data types JS
- Numbers
- Strings of text
- Boolean
2 trivial JS datatypes
- null
- undefined
TRUE OR FALSE:
“JavaScript does not make a distinction between integer values and floating-point values. All numbers in JavaScript are represented as floating-point values.”
TRUE
can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.
JS Variables
used for declaration/initialization of variables
var keyword
has global scope which means it can be defined anywhere in your JavaScript code.
Global Variables
Variable that will be visible only within a function where it is defined. Function parameters are always local to that function.
Local Variables
Do’s and don’ts in JS Variable names?
- should not start with a numeral (0-9).
- must begin with a letter or an underscore character. (Ex. 123test is an invalid variable name but _123test is a valid one.)
- case-sensitive
JS Operators
- Arithmetic Operators
- Comparison Operators
- Logical (or Relational) Operators
- Assignment Operators
- Conditional (or ternary) Operators
Arithmetic Operators
- +
- -
- *
- /
- %
- ++
- –
Comparison Operators
- ==
- !=
- >
- <
- > =
- <=
Logical Operators
- &&
- ||
- !
a unary operator that is placed before its single operand, which can be of any type. Its value is a string indicating the data type of the operand.
typeof Operator
evaluates to “number”, “string”, or “boolean” if its operand is a number, string, or boolean value and returns true or false based on the evaluation.
The typeof operator
While writing a program, there may be a situation when you need to adopt one out of a given set of paths. In such cases, you need to use conditional statements that allow your program to make correct decisions and perform right actions.
JS If-else Statement
To invoke a function somewhere later in the script, you would simply need to write the name of that function
Calling a Function
a value that is passed when declaring a function.
Parameter
Can a function be declared with parameters?
Yes
can be used to return the value to a function call.
return statement
denotes that the function has ended. Any code after return is not executed.
return statement
if nothing is returned, the function returns an?
Undefined value