Javascript, DOM and AJAX Flashcards
What is the format of the HTML script tag?
< script type=”text/javascript” >
// Code here
< /script >
Technically, type attribute is optional in HTML5.
Very old browsers might need the code inside the script tag commented out with < !– and – >
What is the noscript tag?
Inverse of the script tag. Content shows when JS is not available. It is deprecated and not necessary if you create JS that is unobtrusive.
Easiest way to prompt and alert user.
With
var name = prompt(“Enter your name”, “”);
and
alert(“Hello, “ + name);
How to return the type of a variable?
typeof() returns type of data passed to it.
How to convert a float to an integer?
parseInt()
How to explicitly convert string to a number?
Number() or parseFloat() or parseInt()
How to explicitly create a string object?
var myStr = new String(“abc”);