π Welcome to Code.io! π
We're excited to have you here! π
This is your go-to space for everything coding-related. What to expect:
πΉ Daily Coding Challenges π§©
πΉ Programming Tips & Tutorials π
πΉ Tech News & Updates π
πΉ Community Support β Ask questions, share ideas, and collaborate! π Donβt forget to turn on notifications to stay updated on the latest content!
Letβs code, learn, and grow together! πͺ
β€1
1. What is the difference between var, let, and const in JavaScript?
Anonymous Quiz
8%
A)var is block-scoped, let is function-scoped, and const can be re-assigned.
83%
B)var is function-scoped, let is block-scoped, and const is constant and cannot be re-assigned.
0%
C)var and let are the same, but const is used only for objects.
8%
D)var, let, and const are all the same in terms of scope.
2. What will the following code log to the console?console.log(2 + '2');
Anonymous Quiz
69%
A) 22
15%
B) 4
8%
C) undefined
8%
D) Error
3. What does === do in JavaScript?
Anonymous Quiz
8%
A) Compares only values, ignoring the type.
67%
B) Compares both value and type
0%
C) Assigns values to variables.
25%
D) Returns a boolean indicating if two values are equal.
let a = 10;
function foo() {
a = 20; console.log(a); } foo(); console.log(a);
function foo() {
a = 20; console.log(a); } foo(); console.log(a);
Anonymous Quiz
22%
A) 10 and 10
56%
B) 20 and 10
22%
C) 20 and 20
0%
D) Error
5. What is a JavaScript closure?
Anonymous Quiz
0%
A) A function that defines a loop.
100%
B) A function that returns another function and retains access to the outer functionβs variables.
0%
C) A function that is used to close open tabs in a browser.
0%
D) A JavaScript method that allows for asynchronous operations.
6. What is null vs. undefined in JavaScript?
Anonymous Quiz
14%
A) null means an object, and undefined means no value.
14%
B) null is a variable that has not been initialized, and undefined is the absence of a value.
71%
C) null represents no value, and undefined means a variable is declared but not yet assigned.
0%
D) null and undefined are the same.
7. What will the following code output? const arr = [1, 2, 3];
arr[10] = 5;
console.log(arr);
arr[10] = 5;
console.log(arr);
Anonymous Quiz
14%
A) [1, 2, 3, 5]
57%
B) [1, 2, 3, <7 empty items>, 5]
14%
C) [1, 2, 3, 5, undefined]
14%
D) [1, 2, 3, undefined, 5]
8. How can you create a new object in JavaScript?
Anonymous Quiz
14%
A) let person = Object.create(null);
14%
B) let person = new Object();
43%
C) let person = { name: 'Alice', age: 25 };
29%
D) All of the above
9. What is the output of the following code? console.log(typeof NaN);
Anonymous Quiz
18%
A) object
27%
B) undefined
45%
C) number
9%
D) NaN
10. What is the purpose of the this keyword in JavaScript?
Anonymous Quiz
71%
A) Refers to the current function's parameters.
29%
B) Refers to the object in which the function was called.
0%
C) Refers to the global object, regardless of the context.
0%
D) Refers to the last variable declared in the script.
π : Spread the Love! Cloning Arrays Made Easy π
Want to create a quick copy of an array? Use the spread operator (...)! It's super simple:
const originalArray = [1, 2, 3];
const clonedArray = [...originalArray];
console.log(clonedArray); // Output: [1, 2, 3]
β¨ Pro Tip: This creates a shallow copy, so the clonedArray is a fresh array, but if your original array has nested objects, they will still be linked! Keep that in mind for deep copies. π
#JavaScript #CodingTricks #SpreadOperator
What is a void operator? The void operator returns an undefined value from an evaluated expression, or in other words; the void operator specifies an expression to be evaluated without returning a value. It is commonly used in client-side JavaScript, where the browser should not display the value.
function getYear() {
return 2020;
};
console.log(getYear());
// Output: 2020
console.log(void getYear());
// Output: undefined
// Useful use case
button.onclick = () => void getYear();The Worldβs First Web Site
On August 6, 1991, without fanfare, British computer scientist Tim Berners-Lee published the first-ever website while working at CERN, the huge particle physics lab in Switzerland. https://info.cern.ch/hypertext/WWW/TheProject.html
On August 6, 1991, without fanfare, British computer scientist Tim Berners-Lee published the first-ever website while working at CERN, the huge particle physics lab in Switzerland. https://info.cern.ch/hypertext/WWW/TheProject.html
A community platform for developers to share knowledge. Dev.to is a developer-focused social platform where you can read blogs, share articles, and learn from the community. Itβs a great place for beginners and experienced developers alike to discuss new trends, tools, frameworks, and best practices. The platform also hosts discussions, coding tutorials, and personal experiences shared by developers all over the world.π
βCoding is the closest thing we have to a superpower.β
Drew Houston, the Founder of Dropbox
Good luck! πͺ