Image placeholder

超过400+个JavaScript面试问题和答案

Image placeholder
F2EX 2021-06-28

No. Questions
1 What are the possible ways to create objects in JavaScript
2 What is prototype chain
3 What is the difference between Call, Apply and Bind
4 What is JSON and its common operations
5 What is the purpose of the array slice method
6 What is the purpose of the array splice method
7 What is the difference between slice and splice
8 How do you compare Object and Map
9 What is the difference between == and === operators
10 What are lambda or arrow functions
11 What is a first class function
12 What is a first order function
13 What is a higher order function
14 What is a unary function
15 What is the currying function
16 What is a pure function
17 What is the purpose of the let keyword
18 What is the difference between let and var
19 What is the reason to choose the name let as a keyword
20 How do you redeclare variables in switch block without an error
21 What is the Temporal Dead Zone
22 What is IIFE(Immediately Invoked Function Expression)
23 What is the benefit of using modules
24 What is memoization
25 What is Hoisting
26 What are classes in ES6
27 What are closures
28 What are modules
29 Why do you need modules
30 What is scope in javascript
31 What is a service worker
32 How do you manipulate DOM using a service worker
33 How do you reuse information across service worker restarts
34 What is IndexedDB
35 What is web storage
36 What is a post message
37 What is a cookie
38 Why do you need a Cookie
39 What are the options in a cookie
40 How do you delete a cookie
41 What are the differences between cookie, local storage and session storage
42 What is the main difference between localStorage and sessionStorage
43 How do you access web storage
44 What are the methods available on session storage
45 What is a storage event and its event handler
46 Why do you need web storage
47 How do you check web storage browser support
48 How do you check web workers browser support
49 Give an example of web worker
50 What are the restrictions of web workers on DOM
51 What is a promise
52 Why do you need a promise
53 What are the three states of promise
54 What is a callback function
55 Why do we need callbacks
56 What is a callback hell
57 What is server-sent events
58 How do you receive server-sent event notifications
59 How do you check browser support for server-sent events
60 What are the events available for server sent events
61 What are the main rules of promise
62 What is callback in callback
63 What is promise chaining
64 What is promise.all
65 What is the purpose of race method in promise
66 What is a strict mode in javascript
67 Why do you need strict mode
68 How do you declare strict mode
69 What is the purpose of double exclamation
70 What is the purpose of delete operator
71 What is typeof operator
72 What is undefined property
73 What is null value
74 What is the difference between null and undefined
75 What is eval
76 What is the difference between window and document
77 How do you access history in javascript
78 How do you detect caps lock key turned on or not
79 What is isNaN
80 What are the differences between undeclared and undefined variables
81 What are global variables
82 What are the problems with global variables
83 What is NaN property
84 What is the purpose of isFinite function
85 What is an event flow
86 What is event bubbling
87 What is event capturing
88 How do you submit a form using JavaScript
89 How do you find operating system details
90 What is the difference between document load and DOMContentLoaded events
91 What is the difference between native, host and user objects
92 What are the tools or techniques used for debugging JavaScript code
93 What are the pros and cons of promises over callbacks
94 What is the difference between an attribute and a property
95 What is same-origin policy
96 What is the purpose of void 0
97 Is JavaScript a compiled or interpreted language
98 Is JavaScript a case-sensitive language
99 Is there any relation between Java and JavaScript
100 What are events
101 Who created javascript
102 What is the use of preventDefault method
103 What is the use of stopPropagation method
104 What are the steps involved in return false
105 What is BOM
106 What is the use of setTimeout
107 What is the use of setInterval
108 Why is JavaScript treated as Single threaded
109 What is an event delegation
110 What is ECMAScript
111 What is JSON
112 What are the syntax rules of JSON
113 What is the purpose JSON stringify
114 How do you parse JSON string
115 Why do you need JSON
116 What are PWAs
117 What is the purpose of clearTimeout method
118 What is the purpose of clearInterval method
119 How do you redirect new page in javascript
120 How do you check whether a string contains a substring
121 How do you validate an email in javascript
122 How do you get the current url with javascript
123 What are the various url properties of location object
124 How do get query string values in javascript
125 How do you check if a key exists in an object
126 How do you loop through or enumerate javascript object
127 How do you test for an empty object
128 What is an arguments object
129 How do you make first letter of the string in an uppercase
130 What are the pros and cons of for loop
131 How do you display the current date in javascript
132 How do you compare two date objects
133 How do you check if a string starts with another string
134 How do you trim a string in javascript
135 How do you add a key value pair in javascript
136 Is the ‘!–‘ notation represents a special operator
137 How do you assign default values to variables
138 How do you define multiline strings
139 What is an app shell model
140 Can we define properties for functions
141 What is the way to find the number of parameters expected by a function
142 What is a polyfill
143 What are break and continue statements
144 What are js labels
145 What are the benefits of keeping declarations at the top
146 What are the benefits of initializing variables
147 What are the recommendations to create new object
148 How do you define JSON arrays
149 How do you generate random integers
150 Can you write a random integers function to print integers with in a range
151 What is tree shaking
152 What is the need of tree shaking
153 Is it recommended to use eval
154 What is a Regular Expression
155 What are the string methods available in Regular expression
156 What are modifiers in regular expression
157 What are regular expression patterns
158 What is a RegExp object
159 How do you search a string for a pattern
160 What is the purpose of exec method
161 How do you change style of a HTML element
162 What would be the result of 1+2+’3′
163 What is a debugger statement
164 What is the purpose of breakpoints in debugging
165 Can I use reserved words as identifiers
166 How do you detect a mobile browser
167 How do you detect a mobile browser without regexp
168 How do you get the image width and height using JS
169 How do you make synchronous HTTP request
170 How do you make asynchronous HTTP request
171 How do you convert date to another timezone in javascript
172 What are the properties used to get size of window
173 What is a conditional operator in javascript
174 Can you apply chaining on conditional operator
175 What are the ways to execute javascript after page load
176 What is the difference between proto and prototype
177 Give an example where do you really need semicolon
178 What is a freeze method
179 What is the purpose of freeze method
180 Why do I need to use freeze method
181 How do you detect a browser language preference
182 How to convert string to title case with javascript
183 How do you detect javascript disabled in the page
184 What are various operators supported by javascript
185 What is a rest parameter
186 What happens if you do not use rest parameter as a last argument
187 What are the bitwise operators available in javascript
188 What is a spread operator
189 How do you determine whether object is frozen or not
190 How do you determine two values same or not using object
191 What is the purpose of using object is method
192 How do you copy properties from one object to other
193 What are the applications of assign method
194 What is a proxy object
195 What is the purpose of seal method
196 What are the applications of seal method
197 What are the differences between freeze and seal methods
198 How do you determine if an object is sealed or not
199 How do you get enumerable key and value pairs
200 What is the main difference between Object.values and Object.entries method
201 How can you get the list of keys of any object
202 How do you create an object with prototype
203 What is a WeakSet
204 What are the differences between WeakSet and Set
205 List down the collection of methods available on WeakSet
206 What is a WeakMap
207 What are the differences between WeakMap and Map
208 List down the collection of methods available on WeakMap
209 What is the purpose of uneval
210 How do you encode an URL
211 How do you decode an URL
212 How do you print the contents of web page
213 What is the difference between uneval and eval
214 What is an anonymous function
215 What is the precedence order between local and global variables
216 What are javascript accessors
217 How do you define property on Object constructor
218 What is the difference between get and defineProperty
219 What are the advantages of Getters and Setters
220 Can I add getters and setters using defineProperty method
221 What is the purpose of switch-case
222 What are the conventions to be followed for the usage of swtich case
223 What are primitive data types
224 What are the different ways to access object properties
225 What are the function parameter rules
226 What is an error object
227 When you get a syntax error
228 What are the different error names from error object
229 What are the various statements in error handling
230 What are the two types of loops in javascript
231 What is nodejs
232 What is an Intl object
233 How do you perform language specific date and time formatting
234 What is an Iterator
235 How does synchronous iteration works
236 What is an event loop
237 What is call stack
238 What is an event queue
239 What is a decorator
240 What are the properties of Intl object
241 What is an Unary operator
242 How do you sort elements in an array
243 What is the purpose of compareFunction while sorting arrays
244 How do you reversing an array
245 How do you find min and max value in an array
246 How do you find min and max values without Math functions
247 What is an empty statement and purpose of it
248 How do you get meta data of a module
249 What is a comma operator
250 What is the advantage of a comma operator
251 What is typescript
252 What are the differences between javascript and typescript
253 What are the advantages of typescript over javascript
254 What is an object initializer
255 What is a constructor method
256 What happens if you write constructor more than once in a class
257 How do you call the constructor of a parent class
258 How do you get the prototype of an object
259 What happens If I pass string type for getPrototype method
260 How do you set prototype of one object to another
261 How do you check whether an object can be extendable or not
262 How do you prevent an object to extend
263 What are the different ways to make an object non-extensible
264 How do you define multiple properties on an object
265 What is MEAN in javascript
266 What Is Obfuscation in javascript
267 Why do you need Obfuscation
268 What is Minification
269 What are the advantages of minification
270 What are the differences between Obfuscation and Encryption
271 What are the common tools used for minification
272 How do you perform form validation using javascript
273 How do you perform form validation without javascript
274 What are the DOM methods available for constraint validation
275 What are the available constraint validation DOM properties
276 What are the list of validity properties
277 Give an example usage of rangeOverflow property
278 Is enums feature available in javascript
279 What is an enum
280 How do you list all properties of an object
281 How do you get property descriptors of an object
282 What are the attributes provided by a property descriptor
283 How do you extend classes
284 How do I modify the url without reloading the page
285 How do you check whether an array includes a particular value or not
286 How do you compare scalar arrays
287 How to get the value from get parameters
288 How do you print numbers with commas as thousand separators
289 What is the difference between java and javascript
290 Does javascript supports namespace
291 How do you declare namespace
292 How do you invoke javascript code in an iframe from parent page
293 How do get the timezone offset from date
294 How do you load CSS and JS files dynamically
295 What are the different methods to find HTML elements in DOM
296 What is jQuery
297 What is V8 JavaScript engine
298 Why do we call javascript as dynamic language
299 What is a void operator
300 How to set the cursor to wait
301 How do you create an infinite loop
302 Why do you need to avoid with statement
303 What is the output of below for loops
304 List down some of the features of ES6
305 What is ES6
306 Can I redeclare let and const variables
307 Is const variable makes the value immutable
308 What are default parameters
309 What are template literals
310 How do you write multi-line strings in template literals
311 What are nesting templates
312 What are tagged templates
313 What are raw strings
314 What is destructuring assignment
315 What are default values in destructuring assignment
316 How do you swap variables in destructuring assignment
317 What are enhanced object literals
318 What are dynamic imports
319 What are the use cases for dynamic imports
320 What are typed arrays
321 What are the advantages of module loaders
322 What is collation
323 What is for…of statement
324 What is the output of below spread operator array
325 Is PostMessage secure
326 What are the problems with postmessage target origin as wildcard
327 How do you avoid receiving postMessages from attackers
328 Can I avoid using postMessages completely
329 Is postMessages synchronous
330 What paradigm is Javascript
331 What is the difference between internal and external javascript
332 Is JavaScript faster than server side script
333 How do you get the status of a checkbox
334 What is the purpose of double tilde operator
335 How do you convert character to ASCII code
336 What is ArrayBuffer
337 What is the output of below string expression
338 What is the purpose of Error object
339 What is the purpose of EvalError object
340 What are the list of cases error thrown from non-strict mode to strict mode
341 Do all objects have prototypes
342 What is the difference between a parameter and an argument
343 What is the purpose of some method in arrays
344 How do you combine two or more arrays
345 What is the difference between Shallow and Deep copy
346 How do you create specific number of copies of a string
347 How do you return all matching strings against a regular expression
348 How do you trim a string at the beginning or ending
349 What is the output of below console statement with unary operator
350 Does javascript uses mixins
351 What is a thunk function
352 What are asynchronous thunks
353 What is the output of below function calls
354 How to remove all line breaks from a string
355 What is the difference between reflow and repaint
356 What happens with negating an array
357 What happens if we add two arrays
358 What is the output of prepend additive operator on falsy values
359 How do you create self string using special characters
360 How do you remove falsy values from an array
361 How do you get unique values of an array
362 What is destructuring aliases
363 How do you map the array values without using map method
364 How do you empty an array
365 How do you rounding numbers to certain decimals
366 What is the easiest way to convert an array to an object
367 How do you create an array with some data
368 What are the placeholders from console object
369 Is it possible to add CSS to console messages
370 What is the purpose of dir method of console object
371 Is it possible to debug HTML elements in console
372 How do you display data in a tabular format using console object
373 How do you verify that an argument is a Number or not
374 How do you create copy to clipboard button
375 What is the shortcut to get timestamp
376 How do you flattening multi dimensional arrays
377 What is the easiest multi condition checking
378 How do you capture browser back button
379 How do you disable right click in the web page
380 What are wrapper objects
381 What is AJAX
382 What are the different ways to deal with Asynchronous Code
383 How to cancel a fetch request
384 What is web speech API
385 What is minimum timeout throttling
386 How do you implement zero timeout in modern browsers
387 What are tasks in event loop
388 What are microtasks
389 What are different event loops
390 What is the purpose of queueMicrotask
391 How do you use javascript libraries in typescript file
392 What are the differences between promises and observables
393 What is heap
394 What is an event table
395 What is a microTask queue
396 What is the difference between shim and polyfill
397 How do you detect primitive or non primitive value type
398 What is babel
399 Is Node.js completely single threaded
400 What are the common use cases of observables
401 What is RxJS
402 What is the difference between Function constructor and function declaration
403 What is a Short circuit condition
404 What is the easiest way to resize an array
405 What is an observable
406 What is the difference between function and class declarations
407 What is an async function
408 How do you prevent promises swallowing errors
409 What is deno
410 How do you make an object iterable in javascript
411 What is a Proper Tail Call
412 How do you check an object is a promise or not
413 How to detect if a function is called as constructor
414 What are the differences between arguments object and rest parameter
415 What are the differences between spread operator and rest parameter
416 What are the different kinds of generators
417 What are the built-in iterables
418 What are the differences between for…of and for…in statements
419 How do you define instance and non-instance properties
420 What is the difference between isNaN and Number.isNaN?
421 How to invoke an IIFE without any extra brackets?
422 Is that possible to use expressions in switch cases?
423 What is the easiest way to ignore promise errors?
424 How do style the console output using CSS?

2021-06-28