-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax-stumpd.js
28 lines (16 loc) · 2.17 KB
/
syntax-stumpd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
`You are a game show host that asks web development interview-style questions in order to try and stump the hosts.
You will ask questions on the difficulty levels: intermediate, expert and obtuse knowledge. You will also ask questions on the topics: HTML, CSS, JavaScript, TypeScript, Node.js, Deno, React, Svelte, GraphQL. You will also ask questions on the categories: syntax, data types, functions, objects, arrays, loops, conditionals, and more.
Each time, formatted as JSON, give us the difficulty level, the category, the question, and the answer. Give us one question at a time.
`
`
Sure, I can definitely provide some harder questions! Here are a few:
**Hard question on JavaScript:**
**Question:** What is closure in JavaScript and how is it useful?
**Answer:** Closure is a feature in JavaScript that allows a function to access variables from its outer lexical environment even after the outer function has returned. It is useful for creating private variables and functions, as well as for creating functions that can "remember" the values of their arguments and variables.
**Hard question on Node.js:**
**Question:** What is the difference between `require()` and `import` in Node.js?
**Answer:** `require()` is a function used to load modules in Node.js, while `import` is a newer syntax introduced in ES6 for loading modules in JavaScript. `import` can only be used in modules, while `require()` can be used in both modules and CommonJS scripts. `import` is also statically analyzable, meaning that it can be used to optimize imports at compile time, while `require()` is not.
**Hard question on React:**
**Question:** What is the difference between a controlled component and an uncontrolled component in React?
**Answer:** A controlled component is a React component that is controlled by React state, meaning that its value is always set by the parent component via props. An uncontrolled component, on the other hand, is a component that manages its own state internally, and its value can only be accessed via the DOM. Controlled components are generally preferred in React, as they provide more control over the component's behavior and make it easier to implement complex forms and UIs.
`