518 표시 중
#1 What are the possible ways to create objects in JavaScript Objects & Prototype · junior #2 What is a prototype chain Objects & Prototype · mid #3 What is the Difference Between call, apply, and bind Functions & Scope · junior #4 What is JSON and its common operations Strings, RegExp & JSON · junior #5 What is the purpose of the array slice method Arrays & Iteration · junior #6 What is the purpose of the array splice method Arrays & Iteration · junior #7 What is the difference between slice and splice JavaScript Core · junior #8 How do you compare Object and Map Objects & Prototype · junior #9 What is the difference between == and === operators Language Core · junior #10 What are lambda expressions or arrow functions Functions & Scope · junior #11 What is a first class function Functions & Scope · junior #12 What is a first order function Functions & Scope · junior #13 What is a higher order function Functions & Scope · junior #14 What is a unary function Functions & Scope · junior #15 What is the currying function Functions & Scope · junior #16 What is a pure function Functions & Scope · junior #17 What are the benefits of pure functions Functions & Scope · junior #18 What is the purpose of the let keyword Language Core · junior #19 What is the difference between let and var Language Core · junior #20 What is the reason to choose the name let as a keyword Language Core · junior #21 How do you redeclare variables in a switch block without an error Errors & Debugging · junior #22 What is the Temporal Dead Zone Functions & Scope · junior #23 What is an IIFE (Immediately Invoked Function Expression) Functions & Scope · junior #24 How do you decode or encode a URL in JavaScript? Browser & Web APIs · junior #25 What is memoization JavaScript Core · junior #26 What is Hoisting Functions & Scope · junior #27 What are classes in ES6 Objects & Prototype · junior #28 What are closures Functions & Scope · mid #29 What are modules Modules & Tooling · mid #30 Why do you need modules Modules & Tooling · mid #31 What is scope in javascript Functions & Scope · junior #32 What is a service worker Browser & Web APIs · mid #33 How do you manipulate DOM using a service worker Browser & Web APIs · mid #34 How do you reuse information across service worker restarts Browser & Web APIs · mid #35 What is IndexedDB JavaScript Core · junior #36 What is web storage Browser & Web APIs · junior #37 What is a post message JavaScript Core · junior #38 What is a Cookie Browser & Web APIs · junior #39 Why do you need a Cookie Browser & Web APIs · junior #40 What are the options in a cookie Browser & Web APIs · junior #41 How do you delete a cookie Browser & Web APIs · junior #42 What are the differences between cookie, local storage and session storage Browser & Web APIs · junior #43 What is the main difference between localStorage and sessionStorage Browser & Web APIs · junior #44 How do you access web storage Browser & Web APIs · junior #45 What are the methods available on session storage Browser & Web APIs · junior #46 What is a storage event and its event handler Browser & Web APIs · junior #47 Why do you need web storage Browser & Web APIs · junior #48 How do you check web storage browser support Browser & Web APIs · junior #49 How do you check web workers browser support Browser & Web APIs · mid #50 Give an example of a web worker Browser & Web APIs · mid #51 What are the restrictions of web workers on DOM Browser & Web APIs · mid #52 What is a promise Async & Event Loop · mid #53 Why do you need a promise Async & Event Loop · mid #54 Explain the three states of promise Async & Event Loop · mid #55 What is a callback function Async & Event Loop · junior #56 Why do we need callbacks Async & Event Loop · junior #57 What is a callback hell Async & Event Loop · junior #58 What are server-sent events Async & Event Loop · junior #59 How do you receive server-sent event notifications Async & Event Loop · junior #60 How do you check browser support for server-sent events Async & Event Loop · junior #61 What are the events available for server sent events JavaScript Core · junior #62 What are the main rules of promise Async & Event Loop · mid #63 What is callback in callback Async & Event Loop · junior #64 What is promise chaining Async & Event Loop · mid #65 What is promise.all Async & Event Loop · mid #66 Does Promise.all() cancel the other Promises? Async & Event Loop · mid #67 What is the purpose of the race method in promise Async & Event Loop · mid #68 What is a strict mode in javascript Language Core · junior #69 Why do you need strict mode Language Core · junior #70 How do you declare strict mode Language Core · junior #71 What is the purpose of double exclamation JavaScript Core · junior #72 What is the purpose of the delete operator Language Core · junior #73 What is typeof operator Language Core · junior #74 What is undefined property Objects & Prototype · junior #75 What is null value Language Core · junior #76 What is the difference between null and undefined Language Core · junior #77 What is eval JavaScript Core · junior #78 What is the difference between window and document Browser & Web APIs · junior #79 How do you access history in javascript Browser & Web APIs · junior #80 How do you detect caps lock key turned on or not JavaScript Core · junior #81 What is isNaN Numbers, Date & Intl · junior #82 What are the differences between undeclared and undefined variables Language Core · junior #83 What are global variables Language Core · junior #84 What are the problems with global variables Language Core · junior #85 What is NaN property Objects & Prototype · junior #86 What is the purpose of isFinite function Functions & Scope · junior #87 What is an event flow JavaScript Core · junior #88 What is event capturing JavaScript Core · junior #89 What is event bubbling JavaScript Core · junior #90 How do you submit a form using JavaScript Browser & Web APIs · junior #91 How do you find operating system details JavaScript Core · junior #92 What is the difference between document load and DOMContentLoaded events Browser & Web APIs · junior #93 What is the difference between native, host and user objects Objects & Prototype · junior #94 What are the tools or techniques used for debugging JavaScript code Errors & Debugging · junior #95 What are the pros and cons of promises over callbacks Async & Event Loop · mid #96 What is the difference between an attribute and a property Objects & Prototype · junior #97 What is same-origin policy Security · junior #98 What is the purpose of void 0 JavaScript Core · junior #99 Is JavaScript a compiled or interpreted language Language Core · junior #100 Is JavaScript a case-sensitive language Language Core · junior #101 Is there any relation between Java and JavaScript Language Core · junior #102 What are events JavaScript Core · junior #103 Who created javascript Language Core · junior #104 What is the use of preventDefault method JavaScript Core · junior #105 What is the use of stopPropagation method JavaScript Core · junior #106 What are the steps involved in return false usage JavaScript Core · junior #107 What is BOM JavaScript Core · junior #108 What is the use of setTimeout Async & Event Loop · junior #109 What is the use of setInterval Async & Event Loop · junior #110 Why is JavaScript treated as Single threaded Language Core · junior #111 What is an event delegation JavaScript Core · junior #112 What is ECMAScript Modules & Tooling · junior #113 What is JSON Strings, RegExp & JSON · junior #114 What are the syntax rules of JSON Strings, RegExp & JSON · junior #115 What is the purpose JSON stringify Strings, RegExp & JSON · junior #116 How do you parse JSON string Strings, RegExp & JSON · junior #117 Why do you need JSON Strings, RegExp & JSON · junior #118 What are PWAs Browser & Web APIs · junior #119 What is the purpose of clearTimeout method JavaScript Core · junior #120 What is the purpose of clearInterval method JavaScript Core · junior #121 How do you redirect new page in javascript Language Core · junior #122 How do you check whether a string contains a substring Strings, RegExp & JSON · junior #123 How do you validate an email in javascript Numbers, Date & Intl · junior #124 How do you get the current url with javascript Browser & Web APIs · junior #125 What are the various url properties of location object Objects & Prototype · junior #126 How do you get query string values in javascript Strings, RegExp & JSON · junior #127 How do you check if a key exists in an object Objects & Prototype · junior #128 How do you loop through or enumerate javascript object Objects & Prototype · junior #129 How do you test for an empty object Objects & Prototype · junior #130 What is an arguments object Functions & Scope · junior #131 How do you make first letter of the string in an uppercase Strings, RegExp & JSON · junior #132 What are the pros and cons of for loops Language Core · junior #133 How do you display the current date in javascript Numbers, Date & Intl · junior #134 How do you compare two date objects Objects & Prototype · junior #135 How do you check if a string starts with another string Strings, RegExp & JSON · junior #136 How do you trim a string in javascript Strings, RegExp & JSON · junior #137 How do you add a key value pair in javascript Language Core · junior #138 Is the !-- notation represents a special operator Language Core · junior #139 How do you assign default values to variables Language Core · junior #140 How do you define multiline strings Strings, RegExp & JSON · junior #141 What is an app shell model JavaScript Core · junior #142 Can we define properties for functions Functions & Scope · junior #143 What is the way to find the number of parameters expected by a function Functions & Scope · junior #144 What is a polyfill Modules & Tooling · junior #145 What are break and continue statements JavaScript Core · junior #146 What are js labels Language Core · junior #147 What are the benefits of keeping declarations at the top JavaScript Core · junior #148 What are the benefits of initializing variables Language Core · junior #149 What are the recommendations to create new object Objects & Prototype · junior #150 How do you define JSON arrays Arrays & Iteration · junior #151 How do you generate random integers Browser & Web APIs · junior #152 Can you write a random integers function to print integers within a range Functions & Scope · junior #153 What is tree shaking Performance & Runtime · junior #154 What is the need of tree shaking Performance & Runtime · junior #155 Is it recommended to use eval JavaScript Core · junior #156 What is a Regular Expression Strings, RegExp & JSON · junior #157 What are the string methods that accept Regular expression Strings, RegExp & JSON · junior #158 What are modifiers in regular expression Strings, RegExp & JSON · junior #159 What are regular expression patterns Strings, RegExp & JSON · junior #160 What is a RegExp object Objects & Prototype · junior #161 How do you search a string for a pattern Strings, RegExp & JSON · junior #162 What is the purpose of exec method JavaScript Core · junior #163 How do you change the style of a HTML element JavaScript Core · junior #164 What would be the result of 1+2+'3' JavaScript Core · junior #165 What is a debugger statement Errors & Debugging · junior #166 What is the purpose of breakpoints in debugging Errors & Debugging · junior #167 Can I use reserved words as identifiers JavaScript Core · junior #168 How do you detect a mobile browser Browser & Web APIs · junior #169 How do you detect a mobile browser without regexp Strings, RegExp & JSON · junior #170 How do you get the image width and height using JS Browser & Web APIs · junior #171 How do you make synchronous HTTP request JavaScript Core · junior #172 How do you make asynchronous HTTP request Async & Event Loop · mid #173 How do you convert date to another timezone in javascript Numbers, Date & Intl · junior #174 What are the properties used to get size of window Browser & Web APIs · junior #175 What is a conditional operator in javascript Language Core · junior #176 Can you apply chaining on conditional operator Functions & Scope · junior #177 What are the ways to execute javascript after a page load Browser & Web APIs · junior #178 What is the difference between proto and prototype Objects & Prototype · mid #179 Can you give an example of when you really need a semicolon Language Core · junior #180 What is the freeze method Objects & Prototype · junior #181 What is the purpose of the freeze method Objects & Prototype · junior #182 Why do I need to use the freeze method Objects & Prototype · junior #183 How do you detect a browser language preference Browser & Web APIs · junior #184 How to convert a string to title case with javascript Strings, RegExp & JSON · junior #185 How do you detect if javascript is disabled on the page Language Core · junior #186 What are various operators supported by javascript Language Core · junior #187 What is a rest parameter Functions & Scope · junior #188 What happens if you do not use rest parameter as a last argument Functions & Scope · junior #189 What are the bitwise operators available in javascript Language Core · junior #190 What is a spread operator Arrays & Iteration · junior #191 How do you determine whether object is frozen or not Objects & Prototype · junior #192 How do you determine two values same or not using object Objects & Prototype · junior #193 What is the purpose of using object is method Objects & Prototype · junior #194 How do you copy properties from one object to other Objects & Prototype · junior #195 What are the applications of the assign method JavaScript Core · junior #196 What is a proxy object Objects & Prototype · mid #197 What is the purpose of the seal method Objects & Prototype · junior #198 What are the applications of the seal method Objects & Prototype · junior #199 What are the differences between the freeze and seal methods Objects & Prototype · junior #200 How do you determine if an object is sealed or not Objects & Prototype · junior #201 How do you get enumerable key and value pairs Language Core · junior #202 What is the main difference between Object.values and Object.entries method Objects & Prototype · junior #203 How can you get the list of keys of any object Objects & Prototype · junior #204 How do you create an object with a prototype Objects & Prototype · mid #205 What is a WeakSet Objects & Prototype · junior #206 What are the differences between WeakSet and Set Objects & Prototype · junior #207 List down the collection of methods available on WeakSet Objects & Prototype · junior #208 What is a WeakMap Objects & Prototype · junior #209 What are the differences between WeakMap and Map Objects & Prototype · junior #210 List down the collection of methods available on WeakMap Objects & Prototype · junior #211 What is the purpose of uneval JavaScript Core · junior #212 How do you encode an URL Browser & Web APIs · junior #213 How do you decode an URL Browser & Web APIs · junior #214 How do you print the contents of web page JavaScript Core · junior #215 What is the difference between uneval and eval JavaScript Core · junior #216 What is an anonymous function Functions & Scope · junior #217 What is the precedence order between local and global variables Language Core · junior #218 What are javascript accessors Objects & Prototype · junior #219 How do you define property on Object constructor Objects & Prototype · junior #220 What is the difference between get and defineProperty Objects & Prototype · junior #221 What are the advantages of Getters and Setters Objects & Prototype · junior #222 Can I add getters and setters using defineProperty method Objects & Prototype · junior #223 What is the purpose of switch-case Language Core · junior #224 What are the conventions to be followed for the usage of switch case Language Core · junior #225 What are primitive data types Language Core · junior #226 What are the different ways to access object properties Objects & Prototype · junior #227 What are the function parameter rules Functions & Scope · junior #228 What is an error object Objects & Prototype · junior #229 When do you get a syntax error Errors & Debugging · junior #230 What are the different error names from error object Objects & Prototype · junior #231 What are the various statements in error handling Errors & Debugging · junior #232 What are the two types of loops in javascript Language Core · junior #233 What is nodejs Node, Deno & Ecosystem · junior #234 What is the Intl object Objects & Prototype · mid #235 How do you perform language specific date and time formatting Browser & Web APIs · junior #236 What is an Iterator Arrays & Iteration · mid #237 How does synchronous iteration works JavaScript Core · junior #238 What is the event loop Async & Event Loop · mid #239 What is the call stack Functions & Scope · junior #240 What is the event queue JavaScript Core · junior #241 What is a decorator JavaScript Core · mid #242 What are the properties of the Intl object Objects & Prototype · mid #243 What is an Unary operator Language Core · junior #244 How do you sort elements in an array Arrays & Iteration · junior #245 What is the purpose of compareFunction while sorting arrays Functions & Scope · junior #246 How do you reverse an array Arrays & Iteration · junior #247 How do you find the min and max values in an array Arrays & Iteration · junior #248 How do you find the min and max values without Math functions Functions & Scope · junior #249 What is an empty statement and purpose of it JavaScript Core · junior #250 How do you get the metadata of a module Modules & Tooling · mid #251 What is the comma operator Language Core · junior #252 What is the advantage of the comma operator Language Core · junior #253 What is typescript Modules & Tooling · junior #254 What are the differences between javascript and typescript Modules & Tooling · junior #255 What are the advantages of typescript over javascript Modules & Tooling · junior #256 What is an object initializer Objects & Prototype · junior #257 What is a constructor method Language Core · junior #258 What happens if you write constructor more than once in a class Objects & Prototype · junior #259 How do you call the constructor of a parent class Functions & Scope · junior #260 How do you get the prototype of an object Objects & Prototype · mid #261 What happens If I pass string type for getPrototype method Objects & Prototype · mid #262 How do you set the prototype of one object to another Objects & Prototype · mid #263 How do you check whether an object can be extended or not Objects & Prototype · junior #264 How do you prevent an object from being extend Objects & Prototype · junior #265 What are the different ways to make an object non-extensible Objects & Prototype · junior #266 How do you define multiple properties on an object Objects & Prototype · junior #267 What is the MEAN stack Node, Deno & Ecosystem · junior #268 What is obfuscation in javascript Security · junior #269 Why do you need Obfuscation Security · junior #270 What is Minification Performance & Runtime · junior #271 What are the advantages of minification Performance & Runtime · junior #272 What are the differences between obfuscation and Encryption Security · junior #273 What are the common tools used for minification Performance & Runtime · junior #274 How do you perform form validation using javascript Browser & Web APIs · junior #275 How do you perform form validation without javascript Browser & Web APIs · junior #276 What are the DOM methods available for constraint validation Browser & Web APIs · junior #277 What are the available constraint validation DOM properties Browser & Web APIs · junior #278 What are the validity properties JavaScript Core · junior #279 Give an example usage of the rangeOverflow property Objects & Prototype · junior #280 Are enums available in javascript Language Core · junior #281 What is an enum Language Core · junior #282 How do you list all properties of an object Objects & Prototype · junior #283 How do you get property descriptors of an object Objects & Prototype · junior #284 What are the attributes provided by a property descriptor Objects & Prototype · junior #285 How do you extend classes Objects & Prototype · junior #286 How do I modify the url without reloading the page Browser & Web APIs · junior #287 How do you check whether or not an array includes a particular value Arrays & Iteration · junior #288 How do you compare scalar arrays Arrays & Iteration · junior #289 How to get the value from get parameters Functions & Scope · junior #290 How do you print numbers with commas as thousand separators Numbers, Date & Intl · junior #291 What is the difference between java and javascript Language Core · junior #292 Does JavaScript support namespaces Language Core · junior #293 How do you declare a namespace JavaScript Core · junior #294 How do you invoke javascript code in an iframe from the parent page Browser & Web APIs · junior #295 How do you get the timezone offset of a date object Objects & Prototype · junior #296 How do you load CSS and JS files dynamically JavaScript Core · junior #297 What are the different methods to find HTML elements in DOM Browser & Web APIs · junior #298 What is jQuery Node, Deno & Ecosystem · junior #299 What is V8 JavaScript engine Performance & Runtime · senior #300 Why do we call javascript as dynamic language Functions & Scope · junior #301 What is a void operator Language Core · junior #302 How to set the cursor to wait Objects & Prototype · junior #303 How do you create an infinite loop Numbers, Date & Intl · junior #304 Why do you need to avoid with statement JavaScript Core · junior #305 What is the output of the following for loops Language Core · junior #306 List down some of the features of ES6 Modules & Tooling · junior #307 What is ES6 Modules & Tooling · junior #308 Can I redeclare let and const variables Language Core · junior #309 Does the const variable make the value immutable Language Core · junior #310 What are default parameters Functions & Scope · junior #311 What are template literals Strings, RegExp & JSON · junior #312 How do you write multi-line strings in template literals Strings, RegExp & JSON · junior #313 What are nesting templates JavaScript Core · junior #314 What are tagged templates Strings, RegExp & JSON · junior #315 What are raw strings Strings, RegExp & JSON · junior #316 What is destructuring assignment Arrays & Iteration · junior #317 What are default values in destructuring assignment Arrays & Iteration · junior #318 How do you swap variables in destructuring assignment Arrays & Iteration · junior #319 What are enhanced object literals Objects & Prototype · junior #320 What are dynamic imports Modules & Tooling · mid #321 What are the use cases for dynamic imports Modules & Tooling · mid #322 What are typed arrays Arrays & Iteration · mid #323 What are the advantages of module loaders Modules & Tooling · mid #324 What is collation JavaScript Core · junior #325 What is for...of statement Arrays & Iteration · junior #326 What is the output of below spread operator array Arrays & Iteration · junior #327 Is PostMessage secure Browser & Web APIs · mid #328 What are the problems with postmessage target origin as wildcard Browser & Web APIs · mid #329 How do you avoid receiving postMessages from attackers Browser & Web APIs · mid #330 Can I avoid using postMessages completely Browser & Web APIs · mid #331 Is postMessages synchronous Browser & Web APIs · mid #332 What paradigm is Javascript Language Core · junior #333 What is the difference between internal and external javascript Language Core · junior #334 Is JavaScript faster than server side script Language Core · junior #335 How do you get the status of a checkbox Browser & Web APIs · junior #336 What is the purpose of double tilde operator Language Core · junior #337 How do you convert character to ASCII code Numbers, Date & Intl · junior #338 What is ArrayBuffer Arrays & Iteration · mid #339 What is the output of below string expression Strings, RegExp & JSON · junior #340 What is the purpose of Error object Objects & Prototype · junior #341 What is the purpose of EvalError object Objects & Prototype · junior #342 What are the list of cases error thrown from non-strict mode to strict mode Errors & Debugging · junior #343 Do all objects have prototypes Objects & Prototype · mid #344 What is the difference between a parameter and an argument Functions & Scope · junior #345 What is the purpose of some method in arrays Arrays & Iteration · junior #346 How do you combine two or more arrays Arrays & Iteration · junior #347 What is the difference between Shallow and Deep copy JavaScript Core · junior #348 How do you create specific number of copies of a string Strings, RegExp & JSON · junior #349 How do you return all matching strings against a regular expression Strings, RegExp & JSON · junior #350 How do you trim a string at the beginning or ending Strings, RegExp & JSON · junior #351 What is the output of below console statement with unary operator Language Core · junior #352 Does javascript uses mixins Language Core · junior #353 Mixin Example using Object composition Functions & Scope · junior #354 Benefits JavaScript Core · junior #355 What is a thunk function Async & Event Loop · junior #356 What are asynchronous thunks Async & Event Loop · mid #357 What is the output of below function calls Functions & Scope · junior #358 How to remove all line breaks from a string Strings, RegExp & JSON · junior #359 What is the difference between reflow and repaint Performance & Runtime · junior #360 What happens with negating an array Arrays & Iteration · junior #361 What happens if we add two arrays Arrays & Iteration · junior #362 What is the output of prepend additive operator on falsy values Language Core · junior #363 How do you create self string using special characters Strings, RegExp & JSON · junior #364 How do you remove falsy values from an array Arrays & Iteration · junior #365 How do you get unique values of an array Arrays & Iteration · junior #366 What is destructuring aliases Arrays & Iteration · junior #367 How do you map the array values without using map method Objects & Prototype · junior #368 How do you empty an array Arrays & Iteration · junior #369 How do you round numbers to certain decimals Numbers, Date & Intl · junior #370 What is the easiest way to convert an array to an object Objects & Prototype · junior #371 How do you create an array with some data Arrays & Iteration · junior #372 What are the placeholders from console object Objects & Prototype · junior #373 Is it possible to add CSS to console messages JavaScript Core · junior #374 What is the purpose of dir method of console object Objects & Prototype · junior #375 Is it possible to debug HTML elements in console Errors & Debugging · junior #376 How do you display data in a tabular format using console object Objects & Prototype · junior #377 How do you verify that an argument is a Number or not Functions & Scope · junior #378 How do you create copy to clipboard button Browser & Web APIs · junior #379 What is the shortcut to get timestamp Numbers, Date & Intl · junior #380 How do you flattening multi dimensional arrays Arrays & Iteration · junior #381 What is the easiest multi condition checking JavaScript Core · junior #382 How do you capture browser back button Browser & Web APIs · junior #383 How do you disable right click in the web page JavaScript Core · junior #384 What are wrapper objects Objects & Prototype · junior #385 What is AJAX JavaScript Core · junior #386 What are the different ways to deal with Asynchronous Code Async & Event Loop · mid #387 How to cancel a fetch request Async & Event Loop · junior #388 What is web speech API Browser & Web APIs · junior #389 What is minimum timeout throttling JavaScript Core · junior #390 How do you implement zero timeout in modern browsers Browser & Web APIs · junior #391 What are tasks in event loop Async & Event Loop · mid #392 What is microtask Async & Event Loop · mid #393 What are different event loops Async & Event Loop · mid #394 What is the purpose of queueMicrotask Async & Event Loop · mid #395 How do you use javascript libraries in typescript file Modules & Tooling · junior #396 What are the differences between promises and observables Async & Event Loop · mid #397 What is heap Performance & Runtime · junior #398 What is an event table JavaScript Core · junior #399 What is a microTask queue Async & Event Loop · mid #400 What is the difference between shim and polyfill Modules & Tooling · junior #401 How do you detect primitive or non primitive value type Language Core · junior #402 What is babel Modules & Tooling · junior #403 Is Node.js completely single threaded Node, Deno & Ecosystem · junior #404 What are the common use cases of observables Async & Event Loop · mid #405 What is RxJS Async & Event Loop · mid #406 What is the difference between Function constructor and function declaration Functions & Scope · junior #407 What is a Short circuit condition JavaScript Core · junior #408 What is the easiest way to resize an array Arrays & Iteration · junior #409 What is an observable Async & Event Loop · mid #410 What is the difference between function and class declarations Functions & Scope · junior #411 What is an async function Async & Event Loop · mid #412 How do you prevent promises swallowing errors Async & Event Loop · mid #413 What is deno Node, Deno & Ecosystem · junior #414 How do you make an object iterable in javascript Objects & Prototype · junior #415 What is a Proper Tail Call Functions & Scope · senior #416 How do you check an object is a promise or not Async & Event Loop · mid #417 How to detect if a function is called as constructor Functions & Scope · junior #418 What are the differences between arguments object and rest parameter Functions & Scope · junior #419 What are the differences between spread operator and rest parameter Functions & Scope · junior #420 What are the different kinds of generators Arrays & Iteration · mid #421 What are the built-in iterables Arrays & Iteration · junior #422 What are the differences between for...of and for...in statements Arrays & Iteration · junior #423 How do you define instance and non-instance properties JavaScript Core · junior #424 What is the difference between isNaN and Number.isNaN? Numbers, Date & Intl · junior #425 How to invoke an IIFE without any extra brackets? Functions & Scope · junior #426 Is that possible to use expressions in switch cases? Language Core · junior #427 What is the easiest way to ignore promise errors? Async & Event Loop · mid #428 How do style the console output using CSS? JavaScript Core · junior #429 What is nullish coalescing operator (??)? Language Core · junior #430 How do you group and nest console output? JavaScript Core · mid #431 What is the difference between dense and sparse arrays? Arrays & Iteration · mid #432 What are the different ways to create sparse arrays? Arrays & Iteration · mid #433 What is the difference between setTimeout, setImmediate and process.nextTick? Async & Event Loop · mid #434 How do you reverse an array without modifying original array? Arrays & Iteration · mid #435 How do you create custom HTML element? Browser & Web APIs · mid #436 What is global execution context? Functions & Scope · senior #437 What is function execution context? Functions & Scope · senior #438 What is debouncing? JavaScript Core · mid #439 What is throttling? JavaScript Core · mid #440 What is optional chaining? JavaScript Core · mid #441 What is an environment record? JavaScript Core · senior #442 How to verify if a variable is an array? Arrays & Iteration · mid #443 What is pass by value and pass by reference? JavaScript Core · mid #444 What are the differences between primitives and non-primitives? Language Core · mid #445 How do you create your own bind method using either call or apply method? Functions & Scope · mid #446 What are the differences between pure and impure functions? Functions & Scope · mid #447 What is referential transparency? Functions & Scope · mid #448 What are the possible side-effects in javascript? Functions & Scope · mid #449 What are compose and pipe functions? Functions & Scope · mid #450 What is module pattern? Modules & Tooling · mid #451 What is Function Composition? Functions & Scope · mid #452 How to use await outside of async function prior to ES2022? Async & Event Loop · mid #453 What is the purpose of the this keyword in JavaScript? Functions & Scope · mid #454 What are the uses of closures? Functions & Scope · mid #455 What are the phases of execution context? Functions & Scope · senior #456 What are the possible reasons for memory leaks? Performance & Runtime · senior #457 What are the optimization techniques of V8 engine? Performance & Runtime · senior #458 What are the examples of built-in higher order functions? Functions & Scope · mid #459 What are the benefits higher order functions? Functions & Scope · mid #460 How do you create polyfills for map, filter and reduce methods? Objects & Prototype · mid #461 What is the difference between map and forEach functions? Functions & Scope · mid #462 Give an example of statements affected by automatic semicolon insertion? Language Core · mid #463 What are the event phases of a browser? Browser & Web APIs · mid #464 What are the real world use cases of proxy? Objects & Prototype · mid #465 What are hidden classes? Objects & Prototype · senior #466 What is inline caching? Performance & Runtime · senior #467 What are the different ways to execute external scripts? Modules & Tooling · mid #468 What is Lexical Scope? Functions & Scope · mid #469 How to detect system dark mode in javascript? Language Core · mid #470 What is the purpose of requestAnimationFrame method? Performance & Runtime · mid #471 What is the difference between substring and substr methods? Strings, RegExp & JSON · mid #472 How to find the number of parameters expected by a function? Functions & Scope · mid #473 What is globalThis, and what is the importance of it? Modules & Tooling · mid #474 What are the array mutation methods? Arrays & Iteration · mid #475 What is module scope in JavaScript? Functions & Scope · mid #476 What are shadowing and illegal shadowing? JavaScript Core · mid #477 Why is it important to remove event listeners after use? Modules & Tooling · mid #478 What is structuredClone and how is it used for deep copying objects? Objects & Prototype · mid #479 What is the difference between const and Object.freeze Objects & Prototype · mid #480 What is Promise.any and when should it be used? Async & Event Loop · mid #481 What is BigInt and how is it different from Number? Numbers, Date & Intl · mid #482 What are private class fields in JavaScript? Objects & Prototype · mid #483 What is the Array.prototype.at() method and why is it useful? Objects & Prototype · mid #484 What is top-level await in JavaScript modules? Async & Event Loop · mid #485 What are WeakRef and FinalizationRegistry used for? Performance & Runtime · senior #486 What are logical assignment operators? Language Core · mid #487 What is the Temporal API and why is it proposed as a replacement for Date? Numbers, Date & Intl · mid #488 What is the difference between for loop and forEach Arrays & Iteration · mid #489 What are Symbols and what are their use cases? Objects & Prototype · mid #490 What is the difference between Object.create() and Object.assign()? Objects & Prototype · mid #491 What are generator functions and how do they work? Functions & Scope · mid #492 What is the Reflect API and when should you use it? Objects & Prototype · senior #493 How does JavaScript handle floating point precision issues? Numbers, Date & Intl · mid #494 What are tagged template literals and their practical uses? Strings, RegExp & JSON · mid #495 What is the difference between Object.keys(), Object.values(), and Object.entries()? Objects & Prototype · mid #496 What is the Intl.NumberFormat API and how is it used? Browser & Web APIs · mid #497 How do you implement method chaining in JavaScript? Language Core · mid #498 What are the differences between Map and Object for storing key-value pairs? Objects & Prototype · mid #499 What is the purpose of Symbol.iterator and how do you use it? Objects & Prototype · mid #500 How does the Intersection Observer API work? Browser & Web APIs · mid #501 What are async iterators and how are they different from regular iterators? Async & Event Loop · senior #502 What is the purpose of Object.getOwnPropertyDescriptors()? Objects & Prototype · mid #503 How does Promise.allSettled() differ from Promise.all()? Async & Event Loop · mid #504 What are the performance implications of using try-catch in JavaScript? Browser & Web APIs · mid #505 What is the AbortController API and how is it used? JavaScript Core · mid #506 How do you implement a custom error class in JavaScript? Objects & Prototype · mid #507 What is the difference between synchronous and asynchronous generators? Async & Event Loop · mid #508 What are Proxy traps and what operations can they intercept? Objects & Prototype · senior #509 How does the Mutation Observer API work? Browser & Web APIs · mid #510 What is tail call optimization and does JavaScript support it? Functions & Scope · senior #511 What are the different ways to handle circular references in JSON? Strings, RegExp & JSON · senior #512 How do you implement a singleton pattern in JavaScript? Language Core · mid #513 What is the Performance API and how is it used for measuring performance? Browser & Web APIs · senior #514 What are the differences between SharedArrayBuffer and ArrayBuffer? Arrays & Iteration · senior #515 How do you prevent prototype pollution attacks in JavaScript? Objects & Prototype · senior #516 What is the Atomics API and when should it be used? Performance & Runtime · senior #517 How do you implement a lazy loading pattern for modules? Performance & Runtime · mid #518 What are the best practices for optimizing JavaScript bundle size? Performance & Runtime · senior
JAVASCRIPT Objects & Prototype junior
소스 질문 #1 What are the possible ways to create objects in JavaScript 읽기 관점 Start with the definition, then connect it to runtime behavior.
There are many ways to create objects in javascript as mentioned below:
1. Object literal syntax:
The object literal syntax (or object initializer), is a comma-separated set of name-value pairs wrapped in curly braces.
코드 예제 javascript
var object = {
name: "Sudheer",
age: 34,
};Object literal property values can be of any data type, including array, function, and nested object.
Note: This is one of the easiest ways to create an object and it's most commonly used for creating simple, ad-hoc objects.
2. Object constructor:
The simplest way to create an empty object is using the `Object` constructor. Currently this approach is not recommended.
코드 예제 javascript
var object = new Object();The `Object()` is a built-in constructor function so "new" keyword is not required for creating plain objects. The above code snippet can be re-written as:
코드 예제 javascript
var object = Object();However, `Object()` can be used to either create a plain object or convert a given value into its corresponding object wrapper, whereas `new Object()` is specifically used to explicitly create a new object instance.
3. Object's create method:
The `create` method of Object is used to create a new object by passing the specified prototype object and properties as arguments, i.e., this pattern is helpful to create new objects based on existing objects. In other words, this is useful for setting up prototypal inheritance. The second argument is optional and it is used to create properties on a newly created object.
The following code creates a new empty object whose prototype is null.
코드 예제 javascript
var object = Object.create(null);The following example creates an object along with additional new properties.
코드 예제 javascript
let vehicle = {
wheels: "4",
fuelType: "Gasoline",
color: "Green",
};
let carProps = {
type: {
value: "Volkswagen",
},
model: {
value: "Golf",
},
};
var car = Object.create(vehicle, carProps);
console.log(car);4. Function constructor:
In this approach, create any function and apply the new operator to create object instances. This was the main way to do constructor-based OOP before ES6 classes.
코드 예제 javascript
function Person(name) {
this.name = name;
this.age = 21;
}
var object = new Person("Sudheer");5. Function constructor with prototype:
This is similar to function constructor but it uses prototype for their properties and methods. Using prototype means you're sharing methods/properties across instances, which saves memory and improve performance.
코드 예제 javascript
function Person() {}
Person.prototype.name = "Sudheer";
var object = new Person();This is equivalent to creating an instance with `Object.create` method with a function prototype and then calling that function with an instance and parameters as arguments.
코드 예제 javascript
function func(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
var instance = new func(1, 2, 3);코드 예제 javascript
function func(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
// Create a new instance using function prototype.
var newInstance = Object.create(func.prototype);
// Call the function
var result = func.call(newInstance, 1, 2, 3);
// If the result is a non-null object then use it otherwise just use the new instance.
console.log(result && typeof result === 'object' ? result : newInstance);6. Object's assign method:
The `Object.assign` method is used to copy all the properties from one or more source objects and stores them into a target object. This is mainly used for cloning and merging
The following code creates a new staff object by copying properties of his working company and the car he owns.
코드 예제 javascript
const orgObject = { company: "XYZ Corp" };
const carObject = { name: "Toyota" };
const staff = Object.assign({}, orgObject, carObject);7. ES6 Class syntax:
ES6 introduces class feature to create objects. This is syntactic sugar over the prototype-based system.
코드 예제 javascript
class Person {
constructor(name) {
this.name = name;
}
}
var object = new Person("Sudheer");8. Singleton pattern:
A Singleton is an object which can only be instantiated one time. Repeated calls to its constructor return the same instance. This way one can ensure that they don't accidentally create multiple instances.
##### Singleton with Closure (Classic JS Pattern)
코드 예제 javascript
const Singleton = (function () {
let instance;
function createInstance() {
return { name: "Sudheer" };
}
return {
getInstance: function () {
if (!instance) {
instance = createInstance();
}
return instance;
}
};
})();
// Usage
const obj1 = Singleton.getInstance();
const obj2 = Singleton.getInstance();
console.log(obj1 === obj2); // trueIn modern JavaScript applications, singletons are commonly implemented using ES6 modules for their built-in caching behavior, or closures for encapsulated state management.