- Alert Box: Used to give an alert to the user.
- Confirm Box: Used to verify or confirm something from the user. It consists of an ok button, and a cancel button. It returns true when ok is pressed and returns false for cancel.
- Prompt Box: Used to accept input from the user.
window.alert('Hi! I am an ALERT BOX!') window.confirm('Please Confirm me. I am CONFIRM BOX!') window.prompt('I am PROMPT BOX! I am the question', 'I am the default text!')
The void operator is often used merely to obtain the undefined primitive value, usually using "void(0)" (which is equivalent to "void 0"). In these cases, the global variable undefined can be used.
- Alert Box displays only one button that is the OK button.
- Confirm Box displays two buttons. OK button and a Cancel button. Returns true for Ok and false for Cancel.
Escape characters (Backslash) is used when working with special characters like single quotes, double quotes, apostrophes, and ampersands. Place backslash before the characters to make it display.
console.log('Without 'escape' characters!') // prints an error console.log('With \'escape\' character!') // prints: With 'escape' character!
When a browser requests a web page from a server, cookies belonging to the page are added to the request. This way the server gets the necessary data to "remember" information about users.
The pop method removes the last element from an array and returns that value to the caller. pop is intentionally generic; this method can be called or applied to objects resembling arrays.
- The use of innerHTML very slow: The process of using innerHTML is much slower as its contents as slowly built, also already parsed contents and elements are also re-parsed which takes time.
- Content is replaced everywhere: Either you add, append, delete or modify contents on a webpage using innerHTML, all contents are replaced, also all the DOM nodes inside that element are reparsed and recreated.
- Old content replaced issue: The old content is replaced even if object.innerHTML = object.innerHTML + ‘html’ is used instead of object.innerHTML += ‘html’. There is no way of appending without reparsing the whole innerHTML. Therefore, working with innerHTML becomes very slow. String concatenation just does not scale when dynamic DOM elements need to be created as the plus’ and quote openings and closings becomes difficult to track.