An Introduction to JavaScript Flashcards
(37 cards)
javascript was created for what
scripting in the browser
is javascript dynamic
yes meaning you can update elements on the fly
javascript has properties of what two types of languages
oo and functional
can u use js server side?
yes
creating a javascript script
‘script type=”text/javascript”’
window.alert(“hi”);
‘/script’
what does the type signify in declaring a javascript type=”text/javascript”
that everything inside is of type javascript
good practice is to do what
put js code at end of page
write line in js
writeln();
declare a variable
var i=1;
can you execute a js file outside of a browser
yes, using something like jsdb
how to comment in js
single line //
multiline /*
*/
inline comments are available
global variable how to
omit the var and just assign a name to a value
how does var know its type
it is inferred based on what is passed to the variable
get the type of a variable
typeof x;
write a function in js with params and return value
function f(params){return params;}
what is the global context for js
the window object
null
primitive type that represents the absence of a value– evaluates to false
undefined
primitive type represents an unknown or unassigned value
returns when non-existant item is called upon
also evaluates to false
js pi
PI
js method to return as fixed-point notation
tofixed(3)
how are methods invoked on objects etc
the dot i.e. PI.toFixed(3)
Get input from user
Prompt()– you can ALSo concat this with hi+ prompt to output hi and input, and even wrap it in an alert
If you are writing in a .js file do you need to specify that it’s a script
No
how to call a self written js file in same directory
‘script src=”name.js”'’script’