Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript cheatsheet

Finally found out JavaScript Cheatsheet in PDF format :)

Check this 4 JavaScript Cheatsheet in PDF format:
https://buggyprogrammer.com/cheat-sheet-for-javascript
Comment

javascript cheat sheet

Best Cheat Sheet:
https://websitesetup.org/wp-content/uploads/2020/09/Javascript-Cheat-Sheet.pdf
Comment

js Cheat sheet

<script type="text/javascript">

//JS code goes here

</script>
Comment

cheat sheet javascript

if ((age >= 14) && (age < 19)) {        // logical condition
status = "Eligible.";               // executed if condition is true
} else {                                // else block is optional
status = "Not eligible.";           // executed if condition is false
}
Comment

javascript cheatsheet

//get cheatsheet of other languages too
https://github.com/LeCoupa/awesome-cheatsheets/blob/master/languages/javascript.js
https://github.com/mbeaudru/modern-js-cheatsheet
Comment

javascript cheatsheet

document.getElementById("elementID").innerHTML = "Hello World!";
Comment

javascript cheat sheet

/* Convenient interactive cheat sheet */ 'https://htmlcheatsheet.com/js/'
/* PDF VERSION */'https://websitesetup.org/wp-content/uploads/2020/09/Javascript-Cheat-Sheet.pdf'
Comment

js Cheat sheet

<script type="text/javascript">

//JS code goes here

</script>
Comment

Javascript array cheatsheet

// Javascript Array Methods

[3, 4, 5, 6].at(1); // 4
[3, 4, 5, 6].pop(); // [3, 4, 5]
[3, 4, 5, 6].push(7); // [3, 4, 5, 6, 7]
[3, 4, 5, 6].fill(1); // [1, 1, 1, 1]
[3, 4, 5, 6].join("-"); // 3-4-5-6
[3, 4, 5, 6].shift(); // [4, 5, 6]
[3, 4, 5, 6].reverse(); // [6, 5, 4, 3]
[3, 4, 5, 6].unshift(1); // [1, 3, 4, 5, 6]
[3, 4, 5, 6].includes(5); // true
[3, 4, 5, 6].map((num) => num + 6); // [9, 10, 11, 12]
[3, 4, 5, 6].find((num) => num > 4); // 5
[3, 4, 5, 6].filter((num) => num > 4); // [5, 6]
[3, 4, 5, 6].every((num) => num > 5); // false
[3, 4, 5, 6].findeIndex((num) => num > 4); // 2
[3, 4, 5, 6].reduce((acc, num) => acc + num, 0); // 18
Comment

cheat sheet javascript

dogs.toString();                        // convert to string: results "Bulldog,Beagle,Labrador"
dogs.join(" * ");                       // join: "Bulldog * Beagle * Labrador"
dogs.pop();                             // remove last element
dogs.push("Chihuahua");                 // add new element to the end
dogs[dogs.length] = "Chihuahua";        // the same as push
dogs.shift();                           // remove first element
dogs.unshift("Chihuahua");              // add new element to the beginning
delete dogs[0];                         // change element to undefined (not recommended)
dogs.splice(2, 0, "Pug", "Boxer");      // add elements (where, how many to remove, element list)
var animals = dogs.concat(cats,birds);  // join two arrays (dogs followed by cats and birds)
dogs.slice(1,4);                        // elements from [1] to [4-1]
dogs.sort();                            // sort string alphabetically
dogs.reverse();                         // sort string in descending order
x.sort(function(a, b){return a - b});   // numeric sort
x.sort(function(a, b){return b - a});   // numeric descending sort
highest = x[0];                         // first item in sorted array is the lowest (or highest) value
x.sort(function(a, b){return 0.5 - Math.random()});     // random order sort
Comment

JAVASCRIPT CHEATSHEET 1

// STRING
// string[index] - get a certain character of a string
// string.length - return the number of characters in a string
// string.split(' ') - returns an array of words of a string
// string.split('') - returns an array of characters of a string
// string.toLowerCase() - returns a lowercased string
// string.toUpperCase() - returns an uppercased string
// string.includes('subtring') - checks whether a substring exists inside of a string [check the characther case]

// ARRAY
// array[index] - returns a certain value from an array
// array.indexOf('value') - returns the index of the first occurance of that value
// array.length - returns the number of elements in the array
// array.join('') - returns a string of array values
// array.push(value) - adds the value to the end of the array
// array.pop() - removes the value from the end of the array
// array.unshift(value) - adds the value to the start of the array
// array.shift() - removes the value from the start of the array
// array.splice(fromIndex, number_of_elements) - removes the number_of_elements, starting from fromIndex from the array
// array.slice(fromIndex, toIndex) - copies a certain part of the array

// for - looping
const emojis = [ '😀', '😆', '🙃', '😍' ];
const wavingEmojis = [];

for (let i = 0; i < emojis.length; i++) {
   wavingEmojis.push(`👋${emojis[i]}👋`);
}

// forEach - array method for looping
emojis.forEach((emoji) => console.log(emoji));

// map - array method for looping BUT IT HAS RETURNS
const wavingEmojis = emojis.map((emoji) => `👋${emoji}👋`);

// filter
const numbers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ];

const numbersBiggerThanFive = numbers.filter((number) => number > 5);

// sort
const numbers = [ 3, 4, 1, 5, 4, 7, 2, 23, 12 ];

const sortFromSmalles = numbers.sort((a, b) => a - b);
const sortFromLargest = numbers.sort((a, b) => b - a);

// VALUE VS REFERENCE (part 1: intro)
// arrays
const numbers = [ 1, 2, 3, 4 ]; // #123asd
const anotherNumbers = numbers; // #123asd

anotherNumbers.push(5);

// objects
const person = { 
    firstName: 'John', 
    lastName: 'Doe' 
};

const anotherPerson = person;

anotherPerson.lastName = 'DOEEEE';

console.log(numbers === anotherNumbers); // true
console.log(person === anotherPerson) // true

// VALUE VS REFERENCE (part 2: CLONING ARRAYS AND OBJECTS)
// SHALLOW CLONING - ONE LEVEL DEEP
const original = [ 1, 2, 3 ];
const newOriginal = [...original];

// DEEP CLONING - TWO LEVELS DEEP
const users = [ { name: 'John', age: 25 }, { name: 'Victor', age: 25 }, { name: 'Adrian', age: 25 } ];
const newUsers = JSON.parse(JSON.stringify(users));
Comment

js Cheat sheet

<script type="text/javascript">

//JS code goes here

</script>
Comment

js Cheat sheet

<script type="text/javascript">

//JS code goes here

</script>
Comment

js Cheat sheet

<script type="text/javascript">

//JS code goes here

</script>
Comment

dom javascript cheat sheet

<div id='box1'>
  <p>Some example text</p>
</div>
<div id='box2'>
  <p>Some example text</p>
</div>
Comment

javascript cheat sheet

javascript cheat sheet
Comment

js Cheat sheet

<script type="text/javascript">

//JS code goes here

</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: pass element from child to parent react 
Javascript :: spread and rest operator javascript 
Javascript :: export multiple function in node js 
Javascript :: mapbox add a leaflet marker with popup 
Javascript :: angular inner page in refresh 404 after ng build 
Javascript :: prisma.db sqlite 
Javascript :: how to decode jwt token in angular 
Javascript :: accessing json data 
Javascript :: jquery.slim.min.js 
Javascript :: Iterate with JavaScript Do...While Loops 
Javascript :: angular component 
Javascript :: react validation form 
Javascript :: nodemon writefilesync restart problem 
Javascript :: Counting instances of values in an object 
Javascript :: javascript sort strings of object 
Javascript :: merge two sorted linked lists 
Javascript :: mui date picker 
Javascript :: words counter in javascript 
Javascript :: react native position 
Javascript :: handling transaction in sequelize 
Javascript :: v-show example in vue js 
Javascript :: list in react native 
Javascript :: Button get specific input hidden value JQuery 
Javascript :: display json data in html table react 
Javascript :: find if json property is of type date type 
Javascript :: image react native base64 
Javascript :: empty javascript 
Javascript :: how to async javascript stack overflow 
Javascript :: nodejs: router by use express and path package 
Javascript :: fill in javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =