Nov
24
2015
By abernal
Java Script has some important build in functions like
alert()
Sends a message to the user in a small pop up window
Sample
alert("Hello There, this is an Alert Message!!!");
confirm()
Sends a message to the user in a small pop up window in order to confirm a given action (with an Ok and Cancel options)
Sample
confirm("Hello There, are you sure you want to do this ? ");
Return
- if the cancel button is pressed, the return value will be false
- if the ok button is pressed, the return value will be true
prompt()
Sends a message to the user in a small pop up window in order to confirm a given action (with an Ok and Cancel options) with a text field
Sample
var userName = prompt("What is your name?"); confirm("are you sure about your name : " + userName + " ? ");
Return
- if the cancel button is pressed, the return value will be null (an object)
- if there ok button is pressed and there is a string in the text field, the return value will be a string
typeof operator
Return the type of the value within the expression
Sample
typeof true ; // boolean typeof "This is a string" ; // string typeof 42 ; // number typeof undefined ; // undefined typeof null ; // object