JavaScript - Intro Flashcards
Explain Java vs. JavaScript
- Both use dot syntax to drill down into nested objects.
- Syntax is very similar.
- Java is an object oriented programming language developed by Sun Microsystems that is capable of running on multiple operating systems with the use of an interpreter.
- JavaScript, on the other hand, was created by Netscape as a scripting language. It cannot create stand alone applications, but instead resides within the browser.
Even though JavaScript is described as an ______- oriented language, there are no _______. It supports object-oriented programming by using object ________. (While ES6 has a class keyword, it is syntactic sugar over a prototype based structure)
Even though JavaScript is described as an object-oriented language, there are no classes. It supports object-oriented programming by using object prototypes. (While ES6 has a class keyword, it is syntactic sugar over a prototype based structure)
Everything inside of JavaScript is an ______. There are no clear distinctions between _____ and _______.
Everything inside of JavaScript is an object. There are no clear distinctions between types and objects.
Java is _____-based. Objects are divided into _____ and _______ with all inheritance through the class hierarchy.
Java is class-based. Objects are divided into classes and instances with all inheritance through the class hierarchy.
In JavaScript, _____ and ________ can be added to any object dynamically.
In JavaScript, properties and methods can be added to any object dynamically.
n Java, ______ and ______ cannot have properties or methods added dynamically.
In Java, classes and instances cannot have properties or methods added dynamically.
JavaScript is ______ typed. I can assign a String to a variable that was previously a number.
JavaScript is loosely typed. I can assign a String to a variable that was previously a number.
JavaScript objects are _______ arrays. Properties can be accessed via:
JavaScript objects are associative arrays.
Properties can be accessed via: obj.prop or obj[‘prop’].
JavaScript functions are _____ class members. They can be treated like ______ (can be assigned to ______ and passed around like ________)
JavaScript functions are first class members. They can be treated like objects (can be assigned to variables and passed around like variables)
JavaScript does not have to be _______.
JavaScript does not have to be compiled.
JavaScript’s access (through the browser) to the _____ system, _______, ________ on the machine etc is limited.
JavaScript’s access (through the browser) to the file system, databases, hardware on the machine etc is limited.
To add Javascript to your page:
Use script tags in the or . e.g. alert(“Hello World!”);
Separate file.using script tags. e.g. The type attribute is not absolutely required on the html5 spec.
Many developers put their script files at the _____ of the page, just before the closing body tag.
Many developers put their script files at the bottom of the page, just before the closing body tag.
It may improve performance and allows your page to load before it tries to access elements of your page.
If you need your JavaScript to run before the page loads, put your script files at the ______. If you need it to run before (or after) loading an element in your page, put it where you need it.
However, if you need your JavaScript to run before the page loads, put it at the top. If you need it to run before (or after) loading an element in your page, put it where you need it.
Ways to debug in Javascript:
- alert() is convenient but obtrusive
- Use console.log(); and the console in Chrome developer tools
- Chrome developer tools can be used to view and manipulate elements and css, execute code, debug code, view resources, network timeline, request/response details, performance and profiling.
Variables hold ____ or different _____. Here is an example of defining a variable using the var keyword:
Variables hold values or different types.
Example: //An example of variable definition using var var x = 7; //integer (number) x = 3.14 //float (number) x = "Hello!"; //String x = false; //Boolean x = ["I", "am", "an", "array"]; //array x = {name:"IMM", courses:10, awesome:true} //object
List of types of values:
Number String Boolean Array Object Function Date RegExp (used for pattern matching) null (intentional absence of a value) undefined (absence of a value;)