The function which has named at the time of definition is called a named function. For example
I am assuming that js file name is message.js, place the following script tag inside the head tag.
// for Single line comments and
Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout, setInterval and clearInterval.
The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled. The clearInterval(id) function instructs the timer to stop.
Timers are operated within a single thread, and thus events might queue up, waiting to be executed.
"==" checks only for equality in value whereas "===" is a stricter equality test and returns false if either the value or the type of the two variables are different.
An alert box displays only one button which is the OK button.
But a Confirmation box displays two buttons namely OK and cancel.
There are three types of errors:
isNan function returns true if the argument is not a number otherwise it is false.
You can define arrays using the array literal as follows-
var x = ;
var y = [1, 2, 3, 4, 5];
Attributes- provide more details on an element like id, type, value etc.
Property- is the value assigned to the property like type=”text”, value=’Name’ etc.
(i) getElementById(‘idname’): Gets an element by its ID name
(ii) getElementsByClass(‘classname’): Gets all the elements that have the given classname.
(iii) getElementsByTagName(‘tagname’): Gets all the elements that have the given tag name.
(iv) querySelector(): This function takes css style selector and returns the first selected element.
Typed Language is in which the values are associated with values and not with variables. It is of two types:
innerHTML – It will process an HTML tag if found in a string
innerText – It will not process an HTML tag if found in a string
NaN is a short form of Not a Number. Since NaN always compares unequal to any number, including NaN, it is usually used to indicate an error condition for a function that should return a valid number. When a string or something else is being converted into a number and that cannot be done, then we get to see NaN.