Over all Review Flashcards
What is a string?
Strings are blocks of texts. They will always have single or double quotation marks around them.
What is a number?
Numbers are just numbers, they do not have quotes around them.
What is a primitive data type?
String, Number, Boolean
What is a boolean?
true or false
What is undefined?
A variable that does not have a value yet, what you are looking for doesn’t exist.
What is null?
______ is an object that we (developers), set as no value.
What is the || used for?
The logical OR (||) operator for a set of operands is true if and only if one or more of its operands is true
What is are comparison operators?
__________ are used in logical statements to determine equality or difference between variables or values. They are also used to test for true or false.
What is an object?
A data type that can be used to store a collection of data.
What is key:Value pairs?
Objects use key:value pairs to house data. The key is the identifier and the value is the value we want to save to that key.
How do you write a key:value pair?
const user { username: 'your name', password: 'password1234!', age: 43, hobby: 'soccer' }
What are JavaScript Data Types?
Number String Boolean Object Undefined
What is the use of isNaN function?
isNan function returns true if the argument is not a number otherwise it is false.
Between JavaScript and an ASP script, which is faster?
JavaScript is faster. JavaScript is a client-side language and thus it does not need the assistance of the web server to execute.
What is negative infinity?
Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero.
Where do “data types” come into play?
Data you work with in your code is of different - e.g numbers, text, etc.
What object do you use to access the short descriptions for standard HTTP status codes?
http.STATUS_CODES
What are global variables? How are these variables declared and what are the problems associated with using them?
Global variables are those that are available throughout the length of the code, that is, these have no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared.
What is a prompt box?
A prompt box is a box which allows the user to enter input by providing a text box. Label and box will be provided to enter the text or number.
What is the global object we can access the current version of node and arguments passed into the command line?
process
What is ‘this’ keyword in JavaScript?
‘This’ keyword refers to the object from where it was called.
What HTTPS(https) API is available in which environments?
NodeJS
What’s the property on the process object that lists all arguments passed into the command line?
argv
The String object is what type of object?
Native
What is the difference between ViewState and SessionState?
‘ViewState’ is specific to a page in a session.
‘SessionState’ is specific to user-specific data that can be accessed across all pages in the web application.
What is === operator?
=== is called as strict equality operator which returns true when the two operands are having the same value without any type conversion
Explain how can you submit a form using JavaScript?
document.form[0].submit();
Is there anything you have to be careful when using node.cloneNode()?
While cloning, make sure you didn’t duplicate the ID.
How could you prevent multiple event handler to be fired for an event?
If event listeners are attached for the same type event (click, keydown, etc.) of an element for the same event type, you can call event.stopImmediatePropagation() in the first event handler. No other event handler will be executed.
Can you remove an event handler from an element?
Yes. target.removeEventListener(‘click’, handler)
How could you stop further propagation of an event?
Call event.stopPropagation();
How could you prevent a click on an anchor from going to the link?
preventDefault() inside event handler. However, this doesnt stop further propagation.
How could I verify whether one element is child of another?
First check whether the passed parent is the direct parent of the child. If not, keep moving upward to the root of the tree.
What are the different ways to get an element from DOM?
getElementById to get a element that has the provided Id. getElementsByClassName to get a nodelist (nodelist is not an array, rather it is array-like object) by providing a class name. getElementsByTagName to get a nodelist by the provided tag name. querySelector you will pass css style selector (jquery style) and this will retrurn first matched element in the DOM. querySelectorAll will return a non-live nodelist by using depth-first pre order traversal of all the matched elements. Non-live means, any changes after selecting the elements will not be reflected. getElementsByName returns the list of elements by the provided name of the html tag getElementsByTagNameNS returns elements with particular tag name within the provided namespace
window.onload vs document.onload
Does document.onload and window.onload fire at the same time?
window.onload is fired when DOM is ready and all the contents including images, css, scripts, sub-frames, etc. finished loaded. This means everything is loaded.document.onload is fired when DOM (DOM tree built from markup code within the document)is ready which can be prior to images and other external content is loaded.
Think about the differences between window and document, this would be easier for you.
Bonus:document.readyState Returns “loading” while the Document is loading, “interactive” once it is finished parsing but still loading sub-resources, and “complete” once it has loaded. The readystatechange event fires on the Document object when this value changes.
Is there any difference between window and document?
Yes. JavaScript has a global object and everything runs under it. window is that global object that holds global variables, global functions, location, history everything is under it. Besides, setTimeout, ajax call (XMLHttpRequest), console or localStorage are part of window.document is also under window. document is a property of the window object. document represents the DOM and DOM is the object oriented representation of the html markup you have written. All the nodes are part of document. Hence you can use getElementById or addEventListener on document. These methods are not present in the window object.
Can you explain the concept of a CSS float and provide an example of its usage?
CSS float tells the browser to put a particular element to the right side or the left side of the container. I use floats when I’m developing a page that dynamically resizes based on the user resolution.
How do you structure your CSS and JavaScript to make it easier for other developers to work with?
Organize stylesheets with sections for each site component. Each section has comments throughout the code so other developers can change it.
How can JavaScript codes be hidden from old browsers that don’t support JavaScript?
For hiding JavaScript codes from old browsers:
Add “” without the quotes in the code just before the tag.
Old browsers will now treat this JavaScript code as a long HTML comment. While, a browser that supports JavaScript, will take the “” as one-line comments.
What is namespacing in JavaScript and how is it used?
Namespacing is used for grouping the desired functions, variables etc. under a unique name. It is a name that has been attached to the desired functions, objects and properties. This improves modularity in the coding and enables code reuse.
How are JavaScript and ECMA Script related?
ECMA Script are like rules and guideline while Javascript is a scripting language used for web development.
Why it is not advised to use innerHTML in JavaScript?
innerHTML content is refreshed every time and thus is slower. There is no scope for validation in innerHTML and, therefore, it is easier to insert rouge code in the document and, thus, make the web page unstable.
What are the decodeURI() and encodeURI()?
EncodeURl() is used to convert URL into their hex coding. And DecodeURI() is used to convert the encoded URL back to normal.
What is unshift() method ?
unshift() adds the desired number of elements to the start of an array.
What are Screen objects?
Screen objects are used to read the information from the client’s screen. The properties of screen objects are -
AvailHeight: Gives the height of client’s screen
AvailWidth: Gives the width of client’s screen.
ColorDepth: Gives the bit depth of images on the client’s screen
Height: Gives the total height of the client’s screen, including the taskbar
Width: Gives the total width of the client’s screen, including the taskbar.
What is a switch statement?
The switch statement evaluates an expression, matching the expression’s value to a case clause, and executes statements associated with that case, as well as statements in cases that follow the matching case.
What are the various functional components in JavaScript?
First-class functions: Nested functions:
What is a First-class function?
First-class functions: Functions in JavaScript are utilized as first-class objects. Usually can be passed as arguments to other functions, returned as values from other functions, assigned to variables, or can also be stored in data structures.
What is a Nested function?
functions that are defined inside other functions. They are called ‘every time’ the main function is invoked.
What is a higher-order function?
A higher-order function:
Accepts a function as an argument or
Returns a function as a result
What is a callback function?
A call back function is a function that is passed as an argument to another function, to be “called back” at a later time. A function that accepts other functions as arguments is called a higher-order function, which contains the logic for when the callback function gets executed. It’s the combination of these two that allow us to extend our functionality.
Define event bubbling?
JavaScript allows DOM elements to be nested inside each other. If the handler of the child is clicked, the handler of the parent will also work as if it were clicked too.
What is the difference between .call() and .apply()
The function .call() and .apply() are very similar in their usage except a little difference.
.call() is used when the number of the function’s arguments are known to the programmer, as they have to be mentioned as arguments in the call statement.
.apply() is used when the number is not known. The function .apply() expects the argument to be an array.
The basic difference between .call() and .apply() is in the way arguments are passed to the function.
Describe the properties of an anonymous function in JavaScript?
A function that is declared without any named identifier is known as an anonymous function.
Explain the for-in loop?
The for-in loop is used to loop through the properties of an object. The syntax for the for-in loop is -
for (variable name in object){
statement or block to execute
}
In each repetition, one property from the object is associated with the variable name, and the loop is continued till all the properties of the object are depleted.
Explain window.onload and onDocumentReady?
The onload function is not run until all the information on the page is loaded. This leads to a substantial delay before any code is executed.
What is the use of blur function?
Blur function is used to remove the focus from the specified object.
What is a class used for?
A class is used to make properties and methods available on objects of that class type.
What is the use of typeof operator?
‘Typeof’ is an operator which is used to return a string description of the type of a variable.
How generic objects can be created?
Generic objects can be created as: var I = new object()
What is break and continue statements?
Break statement exits from the current loop.
Continue statement continues with next statement of the loop.
Does JavaScript have concept-level scope?
No. JavaScript does not have concept-level scope. The variable declared inside the function has scope inside the function.
What is pop()method in JavaScript?
The pop() method takes the last element off of the given array and returns it. The array on which is called is then altered.
What are JavaScript Cookies?
Cookies are the small test files stored in a computer and it gets created when the user visits the websites to store information that they need.
What are the different types of errors in JavaScript?
Load time errors: Errors which come up when loading a web page like improper syntax errors are known as Load time errors and it generates the errors dynamically.
Run time errors: Errors that come due to misuse of the command inside the HTML language.
Logical Errors: These are the errors that occur due to the bad logic performed on a function which is having different operation.
What are escape characters?
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.
What is the difference between an alert box and a confirmation box?
An alert box displays only one button which is the OK button.
But a Confirmation box displays two buttons namely OK and cancel.
What are all the types of Pop up boxes available in JavaScript?
Alert
Confirm
Prompt
What would be the result of 3+2+”7”?
Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its concatenation will be done. So the result would be 57.
How can you convert the string of any base to integer in JavaScript?
The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter, and the second parameter is the base of the given string. In order to convert 4F (of base 16) to integer, the code used will be - parseInt ("4F", 16);
What are all the looping structures in JavaScript?
For
While
do-while loops
How can the style/class of an element be changed?
document.getElementById(“myText”).style.fontSize = “20”
Or
document.getElementById(“myText”).className = “anyclass”;
What method can you call on a buffer to convert it to a string?
toString()
Does JavaScript support automatic type conversion?
Yes JavaScript does support automatic type conversion, it is the common way of type conversion used by JavaScript developers
What is functional scope?
Functional scope allows us to create variables of functions., that are essentially private to that function.
call will…….
immediately invoke the function
.call you pass in your arguments 1 by 1
apply will…..
immediately invoke the function
.apply you pass in your arguments as an array
bind will……
doesn’t immediately invoke the function
.bind returns a brand new function that will be invoked later
What is a component?
A component is made of several parts: HTML, CSS, or JavaScript brought together for reuse in a website or application.
What does .unshift() do?
will put a new item in the first position of the array
What does .shift() do?
will remove the first item in the array
What does .psuh() do?
adds an item to the end of the array, incrementing its length by 1
What does .pop() do?
removes the last item in the array, decrementing the length by 1
What does a for loop do?
For…of loops are the final for loop type in JavaScript. This for loop type loops over each item in an array, but in this loop, the variable contains the item in the array, not its index number.