|
67 | 67 | | 60 | [Name some JavaScript frameworks and libraries](#60-name-some-javascript-frameworks-and-libraries) |
|
68 | 68 | | 61 | [What is event bubbling and event capturing](#61-what-is-event-bubbling-and-event-capturing) |
|
69 | 69 | | 62 | [What is the role of event.stopPropagation()](#62-what-is-the-role-of-eventstoppropagation) |
|
| 70 | +| 63 | [How can we change the style of an element using javascript](#63-how-can-we-change-the-style-of-an-element-using-javascript) | |
| 71 | +| 64 | [What is object destructuring](#64-what-is-object-destructuring) | |
| 72 | +| 65 | [Difference between an Alert Box and a Confirmation Box](#65-difference-between-an-alert-box-and-a-confirmation-box) | |
| 73 | +| 66 | [How can we handle exceptions with javascript](#66-how-can-we-handle-exceptions-with-javascript) | |
| 74 | +| 67 | [What are the advantages of using External JavaScript](#67-what-are-the-advantages-of-using-external-javascript) | |
70 | 75 |
|
71 | 76 | ### 1. What is JavaScript
|
72 | 77 | * JavaScript is a scripting language used to create dynamic and interactive websites. It is supported by all major web browsers.
|
@@ -969,6 +974,54 @@ This method is used to stop the event from propagating up or down the DOM hierar
|
969 | 974 |
|
970 | 975 | **[:top: Scroll to Top](#javascript-interview-questions)**
|
971 | 976 |
|
| 977 | +### 63. How can we change the style of an element using javascript |
| 978 | +To change the style of an element using JavaScript, we can use the style property of the element's DOM object. |
| 979 | +```js |
| 980 | +document.getElementById("myDiv").style.backgroundColor = "red"; |
| 981 | +``` |
| 982 | +**[:top: Scroll to Top](#javascript-interview-questions)** |
| 983 | + |
| 984 | +### 64. What is object destructuring |
| 985 | +Object destructuring allows you to extract properties from an object and assign them to variables. |
| 986 | +```js |
| 987 | +const fullname = { |
| 988 | + firstName: 'Surbhi', |
| 989 | + lastName: 'Dighe', |
| 990 | +}; |
| 991 | +const { firstName, lastName } = fullname; |
| 992 | +console.log(firstName); // output ========> 'Surbhi' |
| 993 | +console.log(lastName); // output ========> 'Dighe' |
| 994 | +``` |
| 995 | +**[:top: Scroll to Top](#javascript-interview-questions)** |
| 996 | + |
| 997 | +### 65. Difference between an Alert Box and a Confirmation Box |
| 998 | +**Alert Box** - It has only one button, typically labeled "OK" and it is used to display a message to the user. |
| 999 | + |
| 1000 | +**Confirmation Box** - It has two buttons, typically labeled "OK" and "Cancel" and it is used to ask the user to confirm an action. |
| 1001 | + |
| 1002 | +**[:top: Scroll to Top](#javascript-interview-questions)** |
| 1003 | + |
| 1004 | +### 66. How can we handle exceptions with javascript |
| 1005 | +In JavaScript, we can handle exceptions using a try-catch block. The try block contains the code that might throw an exception, and the catch block contains the code that handles the exception if it occurs. |
| 1006 | +```js |
| 1007 | +try { |
| 1008 | + const name = "Surbhi"; |
| 1009 | + console.log(firstname) |
| 1010 | +} catch (error) { |
| 1011 | + console.log("Error: " + error); // output ========> Error: ReferenceError: firstname is not defined |
| 1012 | +} |
| 1013 | +``` |
| 1014 | +**[:top: Scroll to Top](#javascript-interview-questions)** |
| 1015 | + |
| 1016 | +### 67. What are the advantages of using External JavaScript |
| 1017 | +- Improve the load time of web pages |
| 1018 | +- Ease of editing |
| 1019 | +- Code reusability |
| 1020 | +- Separation of Code |
| 1021 | + |
| 1022 | +**[:top: Scroll to Top](#javascript-interview-questions)** |
| 1023 | + |
| 1024 | + |
972 | 1025 | ## Output Based Questions
|
973 | 1026 |
|
974 | 1027 | **1. What will be the output**
|
|
0 commit comments