#_ Important [ JavaScript Built-in Methods ] {CheatSheet}
1. Array Methods
● forEach(): [Link](element => [Link](element));
● map(): const squares = [Link](x => x * x);
● filter(): const evens = [Link](x => x % 2 === 0);
● reduce(): const sum = [Link]((acc, curr) => acc + curr, 0);
● find(): const found = [Link](x => x > 10);
● indexOf(): const index = [Link](item);
● push(): [Link](item);
● pop(): const lastItem = [Link]();
● shift(): const firstItem = [Link]();
● unshift(): [Link](item);
● splice(): [Link](startIndex, deleteCount, item);
● slice(): const sliced = [Link](startIndex, endIndex);
● concat(): const mergedArray = [Link](array2);
● join(): const str = [Link](', ');
● includes(): const hasItem = [Link](item);
● some(): const hasNegative = [Link](x => x < 0);
● every(): const allPositive = [Link](x => x > 0);
● sort(): [Link]((a, b) => a - b);
● reverse(): [Link]();
2. String Methods
● charAt(): const char = [Link](index);
● concat(): const combinedStr = [Link](str2);
● includes(): const hasSubstring = [Link](substring);
● indexOf(): const index = [Link](substring);
● lastIndexOf(): const lastIndex = [Link](substring);
● match(): const matches = [Link](regex);
● repeat(): const repeatedStr = [Link](times);
● replace(): const replacedStr = [Link](regex, newSubstr);
● search(): const index = [Link](regex);
● slice(): const slicedStr = [Link](startIndex, endIndex);
By: Waleed Mousa
● split(): const tokens = [Link](delimiter);
● substring(): const substring = [Link](startIndex, endIndex);
● toLowerCase(): const lowerStr = [Link]();
● toUpperCase(): const upperStr = [Link]();
● trim(): const trimmedStr = [Link]();
3. Object Methods
● [Link](): const keys = [Link](obj);
● [Link](): const values = [Link](obj);
● [Link](): const entries = [Link](obj);
● [Link](): const newObj = [Link]({}, obj1, obj2);
● [Link](): const frozenObj = [Link](obj);
● [Link](): const isFrozen = [Link](obj);
● [Link](): const sealedObj = [Link](obj);
● [Link](): const isSealed = [Link](obj);
● [Link](): const newObj = [Link](prototypeObj);
● [Link](): const hasProp = [Link](prop);
4. Number Methods
● [Link](): const intVal = [Link](string, radix);
● [Link](): const floatVal = [Link](string);
● [Link](): const isNaN = [Link](value);
● [Link](): const isFinite = [Link](value);
● [Link](): const isInteger = [Link](value);
● [Link](): const fixedStr = [Link](digits);
5. Math Functions
● [Link](): const absolute = [Link](num);
● [Link](): const roundedUp = [Link](num);
● [Link](): const roundedDown = [Link](num);
● [Link](): const rounded = [Link](num);
● [Link](): const max = [Link](num1, num2, ...);
● [Link](): const min = [Link](num1, num2, ...);
● [Link](): const power = [Link](base, exponent);
By: Waleed Mousa
● [Link](): const sqrt = [Link](num);
● [Link](): const randomNum = [Link]();
6. Global Functions
● parseInt(): const intVal = parseInt(string, radix);
● parseFloat(): const floatVal = parseFloat(string);
● isNaN(): const isNaN = isNaN(value);
● isFinite(): const isFinite = isFinite(value);
7. Date Methods
● [Link](): const now = [Link]();
● [Link](): const timestamp = [Link](dateString);
● new Date(): const date = new Date(year, month, day, ...);
8. Regular Expression Methods
● [Link](): const matchesPattern = [Link](string);
● [Link](): const match = [Link](string);
9. JSON Methods
● [Link](): const jsonString = [Link](obj);
● [Link](): const obj = [Link](jsonString);
10. Web APIs
● setTimeout(): const timeoutId = setTimeout(() => { /* code */ },
delay);
● clearTimeout(): clearTimeout(timeoutId);
● setInterval(): const intervalId = setInterval(() => { /* code */ },
delay);
● clearInterval(): clearInterval(intervalId);
11. Promises and Asynchronous Programming
● [Link](): [Link](value => { /* code */ });
By: Waleed Mousa
● [Link](): [Link](error => { /* code */ });
● [Link](): [Link](() => { /* code */ });
● [Link](): [Link]([promise1, promise2]).then(values => {
/* code */ });
● [Link](): [Link]([promise1, promise2]).then(value => {
/* code */ });
● async function: async function fetchData() { const data = await
fetch(url); }
12. Console Methods
● [Link](): [Link]('message', obj);
● [Link](): [Link]('warning message');
● [Link](): [Link]('error message');
● [Link](): [Link]('info message');
● [Link](): [Link]();
13. Miscellaneous Methods
● alert(): alert('Alert message');
● confirm(): const confirmed = confirm('Are you sure?');
● prompt(): const userInput = prompt('Enter your name:', 'Default
Name');
● encodeURIComponent(): const encoded =
encodeURIComponent(uriComponent);
● decodeURIComponent(): const decoded =
decodeURIComponent(encodedUriComponent);
14. DOM Manipulation (Web-Specific)
● [Link](): const element =
[Link]('id');
● [Link](): const element =
[Link]('.class');
● [Link](): const elements =
[Link]('div');
● [Link](): const div =
[Link]('div');
By: Waleed Mousa
● [Link](): [Link](childElement);
● [Link]: [Link] = '<span>New content</span>';
● [Link](): [Link]('click',
eventHandler);
● [Link]: [Link] = 'blue';
● [Link](): [Link]('data-custom',
'value');
● [Link](): [Link]('data-custom');
15. Event Handling
● [Link]: [Link] = function() { /* code */ };
● [Link](): [Link]('click',
eventHandler);
● [Link](): [Link]('click',
eventHandler);
● [Link](): [Link]('click', event =>
[Link]());
16. BOM (Browser Object Model) Methods
● [Link](): const newWindow = [Link](url);
● [Link](): [Link]();
● [Link](): [Link](x, y);
● [Link](): [Link](width, height);
17. Web Storage API
● [Link](): [Link]('key', 'value');
● [Link](): const value = [Link]('key');
● [Link](): [Link]('key', 'value');
● [Link](): const value =
[Link]('key');
18. Fetch API and XMLHttpRequest
● fetch(): fetch(url).then(response => [Link]());
● XMLHttpRequest(): const xhr = new XMLHttpRequest(); [Link]('GET',
url); [Link]();
By: Waleed Mousa
19. History API
● [Link](): [Link](stateObj, 'title',
'[Link]');
● [Link](): [Link](stateObj, 'title',
'[Link]');
● [Link](): [Link]();
20. WebSockets
● WebSocket: const socket = new WebSocket('[Link]
21. File and FileReader API
● [Link](): const reader = new FileReader();
[Link](file);
● [Link]: [Link] = function() {
[Link]([Link]); };
22. Geolocation API
● [Link]():
[Link](position =>
[Link](position));
● [Link](): const watchID =
[Link](position =>
[Link](position));
23. Performance API
● [Link](): const start = [Link]();
24. Request Animation Frame
● requestAnimationFrame(): requestAnimationFrame(timestamp => { /*
animations */ });
25. Internationalization
By: Waleed Mousa
● [Link](): const formatter = new
[Link]('en-US'); [Link]([Link](date));
● [Link](): const numberFormatter = new
[Link]('en-US');
[Link]([Link](number));
26. Canvas API
● getContext(): const ctx = [Link]('2d');
27. Drag and Drop API
● ondragstart: [Link] = function(event) { /* code */ };
● ondrop: [Link] = function(event) { /* code */ };
28. Mutation Observer API
● MutationObserver(): const observer = new
MutationObserver(callback); [Link](targetNode, config);
29. Screen API
● [Link]: const screenWidth = [Link];
● [Link]: const screenHeight = [Link];
30. Navigator API
● [Link]: const userAgent = [Link];
● [Link]: const isOnline = [Link];
By: Waleed Mousa