9 underrated skills that make you a better developer:
π§ Logical thinking β structure your thoughts like your code
βοΈ Writing clean commit messages β future-you will thank you
π§ͺ Testing your code β even basic tests prevent big bugs
π£οΈ Explaining code to others β teaches you more than tutorials
π§Ή Refactoring β improve existing code without changing behavior
π Reading documentation β learn straight from the source
π§ Navigating large codebases β essential for real-world projects
π§° Using dev tools β inspect, debug, and optimize your apps
β±οΈ Time management β code smarter, not longer
#coding #tips
π§ Logical thinking β structure your thoughts like your code
βοΈ Writing clean commit messages β future-you will thank you
π§ͺ Testing your code β even basic tests prevent big bugs
π£οΈ Explaining code to others β teaches you more than tutorials
π§Ή Refactoring β improve existing code without changing behavior
π Reading documentation β learn straight from the source
π§ Navigating large codebases β essential for real-world projects
π§° Using dev tools β inspect, debug, and optimize your apps
β±οΈ Time management β code smarter, not longer
#coding #tips
π9π₯2
Common Coding Mistakes to Avoid
Even experienced programmers make mistakes.
Ensure all variables are declared and initialized before use.
Be mindful of JavaScript's automatic type conversion, which can lead to unexpected results.
Understand the difference between global and local scope to avoid unintended variable access.
Carefully review your code for logical inconsistencies that might lead to incorrect output.
Pay attention to array indices and loop conditions to prevent errors in indexing and iteration.
Avoid creating loops that never terminate due to incorrect conditions or missing exit points.
Example:
// Undefined variable error
let result = x + 5; // Assuming x is not declared
// Type coercion error
let age = "30";
let isAdult = age >= 18; // Age will be converted to a number
By being aware of these common pitfalls, you can write more robust and error-free code.
Do you have any specific coding mistakes you've encountered recently?
#javascript #coding #bestpractices
Even experienced programmers make mistakes.
Undefined variables:
Ensure all variables are declared and initialized before use.
Type coercion:
Be mindful of JavaScript's automatic type conversion, which can lead to unexpected results.
Incorrect scope:
Understand the difference between global and local scope to avoid unintended variable access.
Logical errors:
Carefully review your code for logical inconsistencies that might lead to incorrect output.
Off-by-one errors:
Pay attention to array indices and loop conditions to prevent errors in indexing and iteration.
Infinite loops:
Avoid creating loops that never terminate due to incorrect conditions or missing exit points.
Example:
// Undefined variable error
let result = x + 5; // Assuming x is not declared
// Type coercion error
let age = "30";
let isAdult = age >= 18; // Age will be converted to a number
By being aware of these common pitfalls, you can write more robust and error-free code.
Do you have any specific coding mistakes you've encountered recently?
#javascript #coding #bestpractices
π3
β
20 JavaScript Interview Questions
1. What are the different data types in JavaScript
β’ String, Number, Boolean, Undefined, Null, Object, Symbol, BigInt
Use
2. What is the difference between == and ===
β’
β’
3. What is hoisting in JavaScript
Variables and function declarations are moved to the top of their scope before execution.
Only declarations are hoisted, not initializations.
4. What is a closure
A function that remembers variables from its outer scope even after the outer function has finished executing.
Example:
5. What is the difference between var, let, and const
β’
β’
β’
6. What is event delegation
Using a single event listener on a parent element to handle events from its child elements using
7. What is the use of promises in JavaScript
Handle asynchronous operations.
States: pending, fulfilled, rejected
Example:
8. What is async/await
Syntactic sugar over promises for cleaner async code
Example:
9. What is the difference between null and undefined
β’
β’
10. What is the use of arrow functions
Shorter syntax, no own
Example:
11. What is the DOM
Document Object Model β represents HTML as a tree structure. JavaScript can manipulate it using methods like
12. What is the difference between call, apply, and bind
β’
β’
β’
13. What is the use of setTimeout and setInterval
β’
β’
14. What is the difference between stack and heap
β’ Stack: stores primitive values and function calls
β’ Heap: stores objects and reference types
15. What is the use of the spread operator (...)
Expands arrays/objects or merges them
Example:
16. What is the difference between map and forEach
β’
β’
17. What is the use of localStorage and sessionStorage
β’
β’
18. What is a prototype in JavaScript
Every object has a prototype β an object it inherits methods and properties from. Enables inheritance.
19. What is the difference between synchronous and asynchronous code
β’ Synchronous: executes line by line
β’ Asynchronous: executes independently, doesnβt block main thread
20. What are modules in JavaScript
Used to split code into reusable pieces
Example:
π React for more Interview Resources #javascript #interview #coding #webdev #frontend
1. What are the different data types in JavaScript
β’ String, Number, Boolean, Undefined, Null, Object, Symbol, BigInt
Use
typeof
to check a variableβs type.2. What is the difference between == and ===
β’
==
compares values with type coercionβ’
===
compares both value and type (strict equality)3. What is hoisting in JavaScript
Variables and function declarations are moved to the top of their scope before execution.
Only declarations are hoisted, not initializations.
4. What is a closure
A function that remembers variables from its outer scope even after the outer function has finished executing.
Example:
function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
};
}
const counter = outer();
counter(); // 1
5. What is the difference between var, let, and const
β’
var
: function-scoped, can be re-declaredβ’
let
: block-scoped, can be updatedβ’
const
: block-scoped, cannot be re-assigned6. What is event delegation
Using a single event listener on a parent element to handle events from its child elements using
event.target
.7. What is the use of promises in JavaScript
Handle asynchronous operations.
States: pending, fulfilled, rejected
Example:
fetch(url)
.then(res => res.json())
.catch(err => console.error(err));
8. What is async/await
Syntactic sugar over promises for cleaner async code
Example:
async function getData() {
const res = await fetch(url);
const data = await res.json();
console.log(data);
}
9. What is the difference between null and undefined
β’
null
: intentional absence of valueβ’
undefined
: variable declared but not assigned10. What is the use of arrow functions
Shorter syntax, no own
this
bindingExample:
const add = (a, b) => a + b;
11. What is the DOM
Document Object Model β represents HTML as a tree structure. JavaScript can manipulate it using methods like
getElementById
, querySelector
, etc.12. What is the difference between call, apply, and bind
β’
call
: invokes function with arguments passed individuallyβ’
apply
: invokes function with arguments as arrayβ’
bind
: returns a new function with bound context13. What is the use of setTimeout and setInterval
β’
setTimeout
: runs code once after delayβ’
setInterval
: runs code repeatedly at intervals14. What is the difference between stack and heap
β’ Stack: stores primitive values and function calls
β’ Heap: stores objects and reference types
15. What is the use of the spread operator (...)
Expands arrays/objects or merges them
Example:
const arr = [1, 2];
const newArr = [...arr, 3]; // [1, 2, 3]
16. What is the difference between map and forEach
β’
map
: returns a new arrayβ’
forEach
: performs action but returns undefined17. What is the use of localStorage and sessionStorage
β’
localStorage
: persists data even after browser is closedβ’
sessionStorage
: persists data only for session18. What is a prototype in JavaScript
Every object has a prototype β an object it inherits methods and properties from. Enables inheritance.
19. What is the difference between synchronous and asynchronous code
β’ Synchronous: executes line by line
β’ Asynchronous: executes independently, doesnβt block main thread
20. What are modules in JavaScript
Used to split code into reusable pieces
Example:
// file.js
export const greet = () => "Hello";
// main.js
import { greet} from './file.js';
π React for more Interview Resources #javascript #interview #coding #webdev #frontend
β€5π1