{
"iq":[{"id":"1",
"q":"What is JavaScript?",
"answer":"JavaScript is a client-side as well as server side scripting language that can be inserted into HTML pages and is understood by web browsers. JavaScript is also an Object based Programming language"
},
{"id":"2",
"q":"Name some of the JavaScript features.?",
"answer":"JavaScript is a lightweight, interpreted programming language.\n\nJavaScript is designed for creating network-centric applications.\n\nJavaScript is complementary to and integrated with Java.\n\nJavaScript is is complementary to and integrated with HTML.\n\nJavaScript is open and cross-platform. "
},
{"id":"3",
"q":"Is JavaScript a case-sensitive language?",
"answer":"Yes! JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters."
},
{"id":"4",
"q":"What is the use of DOM?",
"answer":"DOM is also known as Document Object Model which is used to develop a model with documents or web pages containing objects like elements, links, etc.\n\nThese objects can be manipulated or certain actions like add, delete or change of an element can be performed using this document object model.\n\nThrough this change in attributes can be done to get all the list of all the elements in the document.\n\nThe DOM model responds to API calls that result in documented level of DOM recommendation.\n\nIt is used to support additional behavior on the web page and use of API give an extensible advantage over other models existing.\n\nDOM codes are reused to meet the requirement of the real world and to make all the program interoperable."
},
{"id":"5",
"q":"What are JavaScript Data Types?",
"answer":"Number\n\nString\n\nBoolean\n\nFunction\n\nObject\n\nUndefined"
},
{"id":"6",
"q":"What is the use of isNaN function?",
"answer":"isNan function returns true if the argument is not a number otherwise it is false."
},
{"id":"7",
"q":"What Is The Difference Between “==” And “===”?",
"answer":"These are the operators provided by JavaScript – strict equality and Type converting equality.\n\nStrict equality (===) returns true if the values which it is going to compare have the same data type. Taking an example, “2” will not be equal to 2 i.e. (“2″===2) will return false.\n\nSecondly, Type converting equality (==), automatically converts the variable to value irrespective of the data type. Taking an example, here “2” will be equal to 2 i.e. (“2″===2) will return true.\n\nSummarizing it, double equal (==) is an autotype converting equality operator while three equals (===) is a strict equality operator, i.e. it will not convert values automatically."
},
{"id":"8",
"q":"What Are JavaScript Data Types?",
"answer":"JavaScript supports three Primary, two Composite and two Special data types. Next, we list down the data types in each of the categories.\n\nPrimary Data Types.\n\nString\n\nNumber\n\nBoolean\n\nComposite Data Types.\n\nObject\n\nArray\n\nSpecial Data Types.\n\nNull\n\nUndefined"
},
{"id":"9",
"q":"How to embed JavaScript in a Web Page?",
"answer":" We can embed the JavaScript very easily in any of the page using the following approach.\n\nExample:\n\n<script language=\"JavaScript\" type=\"text/JavaScript\" >\n\nProgram goes here\n\n</script>"
},
{"id":"10",
"q":"What boolean operators JavaScript support ?",
"answer":"&&(and), ||(or), and !(not). These operators JavaScript supports. && operator both or all conditions should be true. Example:\n\nif( a == 5 && b == 6 )\n\n|| operator only any one condition should be true.\n\nif( a == 5 || b == 6 )\n\n! operator means 'not' so it can be used when you are getting a boolean false value or != (not equal).\n\nExample: if( a != 5 )"
},
{"id":"11",
"q":"What is negative infinity?",
"answer":"Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero."
},
{"id":"12",
"q":"What are undeclared and undefined variables?",
"answer":"Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.\n\nUndefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned."
},
{"id":"13",
"q":" What is a prompt box?",
"answer":" 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."
},
{"id":"14",
"q":"What is ‘this’ keyword in JavaScript?",
"answer":"‘This’ keyword refers to the object from where it was called."
},
{"id":"15",
"q":"What Are JavaScript Cookies?",
"answer":"A cookie is a piece of data which is sent from a website (that owns the requested web page) and gets stored locally by the browser at the user end. Cookies are needed because HTTP protocol which arranges for the transfer of web pages to your browser, is stateless. It means that HTTP has no way to keep track of the activities performed by the user at an earlier point in time. One way to resolve this issue is by using cookies. It contains following data.\n\nA name-value pair containing the actual data.\n\nAn expiry date after which the cookie is no longer valid.\n\nThe domain and path of the server it should be sent to. When a request arrives at the server for a web page that maintains a cookie, the server appends the cookie to the HTTP header to send it across. Server side programs can then read out the information included in it and decide that you have the right to view the page or not and other user preferences.\n\nThus, every time you visit the site that maintains the cookies, your information is available there."
},
{"id":"16",
"q":"Which Built-In Method Adds One Or More Elements To The End Of An Array And Returns The New Length Of The Array?",
"answer":"The push() method adds one or more elements to the end of an array and returns the new length of the array."
},
{"id":"17",
"q":"How can you create an Object in JavaScript?",
"answer":"JavaScript supports Object concept very well. You can create an object using the object literal as follows −\n\nvar emp = {\n\nname: \"Trending\",\n\nage: 10\\n\n}; "
},
{"id":"18",
"q":" How to redirect a url using JavaScript?",
"answer":"To redirect your site visitors to a new page, you just need to add a line in your head section as follows −\n\n<head>\n\n<script type=\"text/javascript\">\n\nwindow.location=\"http://www.some.com\";\n\n</script>\n\n</head>"
},
{"id":"19",
"q":"How to print a web page using javascript?",
"answer":"JavaScript helps you to implement this functionality using print function of window object. The JavaScript print function window.print() will print the current web page when executed."
},
{"id":"20",
"q":"How to create an array in JavaScript?",
"answer":"- We can create an array in JavaScript as following ways :\n\n- For example :\n\n<script>\n\nvar fruits = new Array[];\n\nfruits[0] = “Apple”;\n\nfruits[1] = “Orange”;\n\nfruits[2] = “Banana”;\n\nalert(fruits[1]);\n\n</script>\n\n- It will give output : Orange\n\n - Another easier way to create an array is as follow :\n\n<script>\n\nvar fruits = [“Apple”,”Orange”,”Banana”];\n\nalert(fruits[0]);\n\n</script>\n\n- This will give output : Apple"
},
{"id":"21",
"q":"What is encodeURI() function?",
"answer":"- encodeURI() function is used to encode the URI.\n\n- This function does not encode following special characters :\n\n' = , ? : $ @ / & # + '\n\n- Syntax : encodeURI(uri), Where uri is URI to be encoded. "
},
{"id":"22",
"q":"Can you explain about Screen object? ",
"answer":"The screen object can be used to retrieve the information about the visitor’s screen.\n\nThere are following properties of Screen objects :\n\navalHeight : This property returns the height of the screen excluding the windows taskbar.\n\navailWidth : This property returns the width of the screen excluding the windows taskbar.\n\ncolorDepth : This property returns the bit depth of the color palette to display images.\n\nheight : This property returns the total height of the screen.\n\npixelDepth : This property returns the color resolution of the screen in bits per pixel.\n\nwidth : This property returns the total width of the screen. "
},
{"id":"23",
"q":"What is variable typing?",
"answer":"Variable typing is used to assign a number to a variable and then assign string to the same variable. Example is as follows:\n\nJavaScript\n\ni= 8;\n\ni=”risk”;"
},{"id":"24",
"q":" How to find operating system in the client machine using JavaScript? ",
"answer":"The ‘Navigator.appversion’ is used to find the name of the operating system in the client machine."
},{"id":"25",
"q":" How are JavaScript and ECMA Script related?",
"answer":"ECMA Script are like rules and guideline while Javascript is a scripting language used for web development."
},{"id":"26",
"q":"What is namespacing in JavaScript and how is it used?",
"answer":"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."
},{"id":"27",
"q":"What are Screen objects?",
"answer":"Screen objects are used to read the information from the client’s screen. The properties of screen objects are –\n\nAvailHeight: Gives the height of client’s screen\n\nAvailWidth: Gives the width of client’s screen.\n\nColorDepth: Gives the bit depth of images on the client’s screen\n\nHeight: Gives the total height of the client’s screen, including the taskbar\n\nWidth: Gives the total width of the client’s screen, including the taskbar "
},{"id":"28",
"q":"What is unescape() function? ",
"answer":"The unescape() function is used to decode the encoded string.\n\nSyntax : unescape(string1)\n\nWhere string1 is the string to be decoded.\n\nExample :\n\n<script>\n\ndocument.write(unescape(“Questions%3F%20Get%20from%20us%21”));\n\n</script>\n\nOutput :\n\nQuestions? Get from us!"
},{"id":"29",
"q":"How to manage exception handling in Javascript?",
"answer":"Javascript provides the features of exception handling using try..catch..finally blocks which is much similar to the C# exception handling blocks.\n\nWe have to write the suspected code in try block and all the exceptions that occur in the try block will be caught in catch block."
},{"id":"30",
"q":"How Will You Create A Cookie Using JavaScript? ",
"answer":"The simplest way to create a cookie is to assign a string value to the <document.cookie> object.\n\nIts syntax is as follows.\n\ndocument.cookie = \"key1 = value1; key2 = value2; expires = date\";\n\nHere, “expires” attribute is optional. We have to provide a date or time value for this attribute.\n\nIf we provide a valid value for the date or time, then the cookie will expire at the given date or time and it will not be accessible after that."
},{"id":"31",
"q":"How To Read A Cookie Using JavaScript?",
"answer":"To read a Cookie, we have to access the value of the <document.cookie> object. This <document.cookie> string maintains a list of <name = value> pairs that is separated with semicolons.\n\nWhere,\n\n\"name\" is the name of a cookie and\n\n\"value\" is its string value.\n\nWe use String <split()> function to break the <document.cookie> object to sub-strings.\n\nEach of these sub-strings contains a key-value pair which represents the information related to a Cookie."
},{"id":"32",
"q":"How To Delete A Cookie Using JavaScript?",
"answer":"To delete a Cookie, we have to set its expiry date to a time that occurred in the past. If attempts are made to read a deleted Cookie then, nothing is returned. "
},{"id":"33",
"q":" What Are The Different Objects Used In JavaScript?",
"answer":"JavaScript uses a hierarchical structure, applicable to all the objects created in a document. Following are the objects, used in JavaScript that shows the relationship of one object to another.\n\nWindow Object.\n\nIt is the topmost object in the hierarchy. It refers to the content area of the browser window that consists of HTML documents. Each frame is also a window that has some actions inside it.\n\nDocument Object.\n\nA Document object represents the HTML document that the window will display. It has various properties that refer to other objects, which allow access to and modification of content in the document.\n\nForm Object.\n\nA form object is used to take user data as input for processing. It corresponds to an HTML input form constructed with the <FORM>…</FORM> tag."
},
{"id":"34",
"q":" What is a class?",
"answer":"A class is a collection of objects."
},{"id":"35",
"q":"Difference between == and === operators. ",
"answer":"Both above operators fall in comparison operator category. This operator (==) is known as equality operator while === is strict equality operator.Equality operator only checks for the value while strict equality operator checks for the values and their types too."
},{"id":"36",
"q":"What are the different types of errors supported by JavaScript?",
"answer":"There are many errors that can occur in a system. JavaScript provides a message for all the errors at run time and dynamically generate the error code. The errors that are present :\n\nLoad-time errors :\n\nThese are the errors that come when loading a web page like using of improper syntax and the errors gets detected the moment user loads a page.\n\nRun-time errors :\n\nThese are the errors that comes due to misuse of the language commands used inside the HTML document. This shows that it has loaded but the functionality is not properly integrated.\n\nLogic errors :\n\nThese are the errors that comes due to bad logic performed on a function that is having different operation but it is made to have logic differently.."
},{"id":"37",
"q":" What are Math Constants and Functions using JavaScript?",
"answer":"Math object has two constant : Math.PI and Math.E\n\nMath object has following functions :\n\nMath.abs(val1); :It will give absolute value of val1.\n\nMath.max(val1,val2); :This fuction will return maximum value from val1 and val2.\n\nMath.random(); :This function will return a random number between 0 and 1.\n\nMath.floor(val1) :This function will returns decimal value of val1."
},{"id":"38",
"q":"What is Pop() method in JavaScript?",
"answer":"The pop() method is similar as the shift() method but the difference is that Shift method works at the end of the array.\n\nThe pop() method take the last element off of the given array and returns it. The array on which is called is then altered.\n\nFor example :\n\nvar fruits = [\"apple \", \"banana \", \"mango\"];\n\nconsole.log(fruits.pop() );\n\nconsole.log(fruits);\n\nWe get the following console output :\n\nmango\n\n[\"apple \", \"banana\ “];"
},{"id":"39",
"q":" What is the difference between Object and Instance?",
"answer":"An instance of a user-defined type is called an object. We can instantiate many objects from one class.\n\nAn object is an instance of a class."
},{"id":"40",
"q":"What is a prompt box?",
"answer":"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."
},{"id":"41",
"q":" Which symbol is used for comments in Javascript? ",
"answer":"// for Single line comments\n\n/* For MultiLine Comments*/"
},{"id":"42",
"q":" How can you submit a form using JavaScript?",
"answer":"To submit a form using JavaScript use document.form[0].submit();\n\ndocument.form[0].submit();"
},{"id":"43",
"q":" How to convert JSON Object to String?",
"answer":" var name=['My','public','Notebook']\n\nconsole.log(JSON.stringify(name));."
},
{"id":"44",
"q":"What is callback?",
"answer":" A callback is a plain JavaScript function passed to some method as an argument or option. Some callbacks are just events, called to give the user a chance to react when a certain state is triggered.."
},{"id":"45",
"q":" What is closure?",
"answer":"Closures are created whenever a variable that is defined outside the current scope is accessed from within some inner scope."
},{"id":"46",
"q":" What is the data type of variables of in JavaScript?",
"answer":"All variables in the JavaScript are object data types. "
},{"id":"47",
"q":"Which built-in method returns the length of the string?",
"answer":"length() method returns the length of the string.\n\nvar str = \"My public \";\n\nconsole.log(str.length);"
},{"id":"48",
"q":" How Does The <Array()> Differ From <[]> While Creating A JavaScript Array? ",
"answer":"Both the <Array()> and <[]> works almost the same in JavaScript.\n\nIf we use them as is (i.e. without any argument) to create an array object, then they will result in an array object of zero length. Also, if we pass a string or a list of strings as arguments, even then result will be similar.\n\nHowever, they differ when the input argument is of integer type. In that case, the <Array(n)> statement will create an uninitialized array of size of n. Whereas, the <[n]> statement will create an array of size <1> and assign <n> as value to the first element."
},
{"id":"49",
"q":" How can a value be appended to an array? ",
"answer":"A value can be appended to an array in the given manner –\n\narr[arr.length] = value;"
},{"id":"50",
"q":"What is the way to get the status of a CheckBox?",
"answer":"The status can be acquired as follows –\n\nalert(document.getElementById(‘checkbox1’).checked);\n\nIf the CheckBox will be checked, this alert will return TRUE."
}
]
}
"iq":[{"id":"1",
"q":"What is JavaScript?",
"answer":"JavaScript is a client-side as well as server side scripting language that can be inserted into HTML pages and is understood by web browsers. JavaScript is also an Object based Programming language"
},
{"id":"2",
"q":"Name some of the JavaScript features.?",
"answer":"JavaScript is a lightweight, interpreted programming language.\n\nJavaScript is designed for creating network-centric applications.\n\nJavaScript is complementary to and integrated with Java.\n\nJavaScript is is complementary to and integrated with HTML.\n\nJavaScript is open and cross-platform. "
},
{"id":"3",
"q":"Is JavaScript a case-sensitive language?",
"answer":"Yes! JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters."
},
{"id":"4",
"q":"What is the use of DOM?",
"answer":"DOM is also known as Document Object Model which is used to develop a model with documents or web pages containing objects like elements, links, etc.\n\nThese objects can be manipulated or certain actions like add, delete or change of an element can be performed using this document object model.\n\nThrough this change in attributes can be done to get all the list of all the elements in the document.\n\nThe DOM model responds to API calls that result in documented level of DOM recommendation.\n\nIt is used to support additional behavior on the web page and use of API give an extensible advantage over other models existing.\n\nDOM codes are reused to meet the requirement of the real world and to make all the program interoperable."
},
{"id":"5",
"q":"What are JavaScript Data Types?",
"answer":"Number\n\nString\n\nBoolean\n\nFunction\n\nObject\n\nUndefined"
},
{"id":"6",
"q":"What is the use of isNaN function?",
"answer":"isNan function returns true if the argument is not a number otherwise it is false."
},
{"id":"7",
"q":"What Is The Difference Between “==” And “===”?",
"answer":"These are the operators provided by JavaScript – strict equality and Type converting equality.\n\nStrict equality (===) returns true if the values which it is going to compare have the same data type. Taking an example, “2” will not be equal to 2 i.e. (“2″===2) will return false.\n\nSecondly, Type converting equality (==), automatically converts the variable to value irrespective of the data type. Taking an example, here “2” will be equal to 2 i.e. (“2″===2) will return true.\n\nSummarizing it, double equal (==) is an autotype converting equality operator while three equals (===) is a strict equality operator, i.e. it will not convert values automatically."
},
{"id":"8",
"q":"What Are JavaScript Data Types?",
"answer":"JavaScript supports three Primary, two Composite and two Special data types. Next, we list down the data types in each of the categories.\n\nPrimary Data Types.\n\nString\n\nNumber\n\nBoolean\n\nComposite Data Types.\n\nObject\n\nArray\n\nSpecial Data Types.\n\nNull\n\nUndefined"
},
{"id":"9",
"q":"How to embed JavaScript in a Web Page?",
"answer":" We can embed the JavaScript very easily in any of the page using the following approach.\n\nExample:\n\n<script language=\"JavaScript\" type=\"text/JavaScript\" >\n\nProgram goes here\n\n</script>"
},
{"id":"10",
"q":"What boolean operators JavaScript support ?",
"answer":"&&(and), ||(or), and !(not). These operators JavaScript supports. && operator both or all conditions should be true. Example:\n\nif( a == 5 && b == 6 )\n\n|| operator only any one condition should be true.\n\nif( a == 5 || b == 6 )\n\n! operator means 'not' so it can be used when you are getting a boolean false value or != (not equal).\n\nExample: if( a != 5 )"
},
{"id":"11",
"q":"What is negative infinity?",
"answer":"Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero."
},
{"id":"12",
"q":"What are undeclared and undefined variables?",
"answer":"Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.\n\nUndefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned."
},
{"id":"13",
"q":" What is a prompt box?",
"answer":" 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."
},
{"id":"14",
"q":"What is ‘this’ keyword in JavaScript?",
"answer":"‘This’ keyword refers to the object from where it was called."
},
{"id":"15",
"q":"What Are JavaScript Cookies?",
"answer":"A cookie is a piece of data which is sent from a website (that owns the requested web page) and gets stored locally by the browser at the user end. Cookies are needed because HTTP protocol which arranges for the transfer of web pages to your browser, is stateless. It means that HTTP has no way to keep track of the activities performed by the user at an earlier point in time. One way to resolve this issue is by using cookies. It contains following data.\n\nA name-value pair containing the actual data.\n\nAn expiry date after which the cookie is no longer valid.\n\nThe domain and path of the server it should be sent to. When a request arrives at the server for a web page that maintains a cookie, the server appends the cookie to the HTTP header to send it across. Server side programs can then read out the information included in it and decide that you have the right to view the page or not and other user preferences.\n\nThus, every time you visit the site that maintains the cookies, your information is available there."
},
{"id":"16",
"q":"Which Built-In Method Adds One Or More Elements To The End Of An Array And Returns The New Length Of The Array?",
"answer":"The push() method adds one or more elements to the end of an array and returns the new length of the array."
},
{"id":"17",
"q":"How can you create an Object in JavaScript?",
"answer":"JavaScript supports Object concept very well. You can create an object using the object literal as follows −\n\nvar emp = {\n\nname: \"Trending\",\n\nage: 10\\n\n}; "
},
{"id":"18",
"q":" How to redirect a url using JavaScript?",
"answer":"To redirect your site visitors to a new page, you just need to add a line in your head section as follows −\n\n<head>\n\n<script type=\"text/javascript\">\n\nwindow.location=\"http://www.some.com\";\n\n</script>\n\n</head>"
},
{"id":"19",
"q":"How to print a web page using javascript?",
"answer":"JavaScript helps you to implement this functionality using print function of window object. The JavaScript print function window.print() will print the current web page when executed."
},
{"id":"20",
"q":"How to create an array in JavaScript?",
"answer":"- We can create an array in JavaScript as following ways :\n\n- For example :\n\n<script>\n\nvar fruits = new Array[];\n\nfruits[0] = “Apple”;\n\nfruits[1] = “Orange”;\n\nfruits[2] = “Banana”;\n\nalert(fruits[1]);\n\n</script>\n\n- It will give output : Orange\n\n - Another easier way to create an array is as follow :\n\n<script>\n\nvar fruits = [“Apple”,”Orange”,”Banana”];\n\nalert(fruits[0]);\n\n</script>\n\n- This will give output : Apple"
},
{"id":"21",
"q":"What is encodeURI() function?",
"answer":"- encodeURI() function is used to encode the URI.\n\n- This function does not encode following special characters :\n\n' = , ? : $ @ / & # + '\n\n- Syntax : encodeURI(uri), Where uri is URI to be encoded. "
},
{"id":"22",
"q":"Can you explain about Screen object? ",
"answer":"The screen object can be used to retrieve the information about the visitor’s screen.\n\nThere are following properties of Screen objects :\n\navalHeight : This property returns the height of the screen excluding the windows taskbar.\n\navailWidth : This property returns the width of the screen excluding the windows taskbar.\n\ncolorDepth : This property returns the bit depth of the color palette to display images.\n\nheight : This property returns the total height of the screen.\n\npixelDepth : This property returns the color resolution of the screen in bits per pixel.\n\nwidth : This property returns the total width of the screen. "
},
{"id":"23",
"q":"What is variable typing?",
"answer":"Variable typing is used to assign a number to a variable and then assign string to the same variable. Example is as follows:\n\nJavaScript\n\ni= 8;\n\ni=”risk”;"
},{"id":"24",
"q":" How to find operating system in the client machine using JavaScript? ",
"answer":"The ‘Navigator.appversion’ is used to find the name of the operating system in the client machine."
},{"id":"25",
"q":" How are JavaScript and ECMA Script related?",
"answer":"ECMA Script are like rules and guideline while Javascript is a scripting language used for web development."
},{"id":"26",
"q":"What is namespacing in JavaScript and how is it used?",
"answer":"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."
},{"id":"27",
"q":"What are Screen objects?",
"answer":"Screen objects are used to read the information from the client’s screen. The properties of screen objects are –\n\nAvailHeight: Gives the height of client’s screen\n\nAvailWidth: Gives the width of client’s screen.\n\nColorDepth: Gives the bit depth of images on the client’s screen\n\nHeight: Gives the total height of the client’s screen, including the taskbar\n\nWidth: Gives the total width of the client’s screen, including the taskbar "
},{"id":"28",
"q":"What is unescape() function? ",
"answer":"The unescape() function is used to decode the encoded string.\n\nSyntax : unescape(string1)\n\nWhere string1 is the string to be decoded.\n\nExample :\n\n<script>\n\ndocument.write(unescape(“Questions%3F%20Get%20from%20us%21”));\n\n</script>\n\nOutput :\n\nQuestions? Get from us!"
},{"id":"29",
"q":"How to manage exception handling in Javascript?",
"answer":"Javascript provides the features of exception handling using try..catch..finally blocks which is much similar to the C# exception handling blocks.\n\nWe have to write the suspected code in try block and all the exceptions that occur in the try block will be caught in catch block."
},{"id":"30",
"q":"How Will You Create A Cookie Using JavaScript? ",
"answer":"The simplest way to create a cookie is to assign a string value to the <document.cookie> object.\n\nIts syntax is as follows.\n\ndocument.cookie = \"key1 = value1; key2 = value2; expires = date\";\n\nHere, “expires” attribute is optional. We have to provide a date or time value for this attribute.\n\nIf we provide a valid value for the date or time, then the cookie will expire at the given date or time and it will not be accessible after that."
},{"id":"31",
"q":"How To Read A Cookie Using JavaScript?",
"answer":"To read a Cookie, we have to access the value of the <document.cookie> object. This <document.cookie> string maintains a list of <name = value> pairs that is separated with semicolons.\n\nWhere,\n\n\"name\" is the name of a cookie and\n\n\"value\" is its string value.\n\nWe use String <split()> function to break the <document.cookie> object to sub-strings.\n\nEach of these sub-strings contains a key-value pair which represents the information related to a Cookie."
},{"id":"32",
"q":"How To Delete A Cookie Using JavaScript?",
"answer":"To delete a Cookie, we have to set its expiry date to a time that occurred in the past. If attempts are made to read a deleted Cookie then, nothing is returned. "
},{"id":"33",
"q":" What Are The Different Objects Used In JavaScript?",
"answer":"JavaScript uses a hierarchical structure, applicable to all the objects created in a document. Following are the objects, used in JavaScript that shows the relationship of one object to another.\n\nWindow Object.\n\nIt is the topmost object in the hierarchy. It refers to the content area of the browser window that consists of HTML documents. Each frame is also a window that has some actions inside it.\n\nDocument Object.\n\nA Document object represents the HTML document that the window will display. It has various properties that refer to other objects, which allow access to and modification of content in the document.\n\nForm Object.\n\nA form object is used to take user data as input for processing. It corresponds to an HTML input form constructed with the <FORM>…</FORM> tag."
},
{"id":"34",
"q":" What is a class?",
"answer":"A class is a collection of objects."
},{"id":"35",
"q":"Difference between == and === operators. ",
"answer":"Both above operators fall in comparison operator category. This operator (==) is known as equality operator while === is strict equality operator.Equality operator only checks for the value while strict equality operator checks for the values and their types too."
},{"id":"36",
"q":"What are the different types of errors supported by JavaScript?",
"answer":"There are many errors that can occur in a system. JavaScript provides a message for all the errors at run time and dynamically generate the error code. The errors that are present :\n\nLoad-time errors :\n\nThese are the errors that come when loading a web page like using of improper syntax and the errors gets detected the moment user loads a page.\n\nRun-time errors :\n\nThese are the errors that comes due to misuse of the language commands used inside the HTML document. This shows that it has loaded but the functionality is not properly integrated.\n\nLogic errors :\n\nThese are the errors that comes due to bad logic performed on a function that is having different operation but it is made to have logic differently.."
},{"id":"37",
"q":" What are Math Constants and Functions using JavaScript?",
"answer":"Math object has two constant : Math.PI and Math.E\n\nMath object has following functions :\n\nMath.abs(val1); :It will give absolute value of val1.\n\nMath.max(val1,val2); :This fuction will return maximum value from val1 and val2.\n\nMath.random(); :This function will return a random number between 0 and 1.\n\nMath.floor(val1) :This function will returns decimal value of val1."
},{"id":"38",
"q":"What is Pop() method in JavaScript?",
"answer":"The pop() method is similar as the shift() method but the difference is that Shift method works at the end of the array.\n\nThe pop() method take the last element off of the given array and returns it. The array on which is called is then altered.\n\nFor example :\n\nvar fruits = [\"apple \", \"banana \", \"mango\"];\n\nconsole.log(fruits.pop() );\n\nconsole.log(fruits);\n\nWe get the following console output :\n\nmango\n\n[\"apple \", \"banana\ “];"
},{"id":"39",
"q":" What is the difference between Object and Instance?",
"answer":"An instance of a user-defined type is called an object. We can instantiate many objects from one class.\n\nAn object is an instance of a class."
},{"id":"40",
"q":"What is a prompt box?",
"answer":"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."
},{"id":"41",
"q":" Which symbol is used for comments in Javascript? ",
"answer":"// for Single line comments\n\n/* For MultiLine Comments*/"
},{"id":"42",
"q":" How can you submit a form using JavaScript?",
"answer":"To submit a form using JavaScript use document.form[0].submit();\n\ndocument.form[0].submit();"
},{"id":"43",
"q":" How to convert JSON Object to String?",
"answer":" var name=['My','public','Notebook']\n\nconsole.log(JSON.stringify(name));."
},
{"id":"44",
"q":"What is callback?",
"answer":" A callback is a plain JavaScript function passed to some method as an argument or option. Some callbacks are just events, called to give the user a chance to react when a certain state is triggered.."
},{"id":"45",
"q":" What is closure?",
"answer":"Closures are created whenever a variable that is defined outside the current scope is accessed from within some inner scope."
},{"id":"46",
"q":" What is the data type of variables of in JavaScript?",
"answer":"All variables in the JavaScript are object data types. "
},{"id":"47",
"q":"Which built-in method returns the length of the string?",
"answer":"length() method returns the length of the string.\n\nvar str = \"My public \";\n\nconsole.log(str.length);"
},{"id":"48",
"q":" How Does The <Array()> Differ From <[]> While Creating A JavaScript Array? ",
"answer":"Both the <Array()> and <[]> works almost the same in JavaScript.\n\nIf we use them as is (i.e. without any argument) to create an array object, then they will result in an array object of zero length. Also, if we pass a string or a list of strings as arguments, even then result will be similar.\n\nHowever, they differ when the input argument is of integer type. In that case, the <Array(n)> statement will create an uninitialized array of size of n. Whereas, the <[n]> statement will create an array of size <1> and assign <n> as value to the first element."
},
{"id":"49",
"q":" How can a value be appended to an array? ",
"answer":"A value can be appended to an array in the given manner –\n\narr[arr.length] = value;"
},{"id":"50",
"q":"What is the way to get the status of a CheckBox?",
"answer":"The status can be acquired as follows –\n\nalert(document.getElementById(‘checkbox1’).checked);\n\nIf the CheckBox will be checked, this alert will return TRUE."
}
]
}