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

list of javascript cheat sheet

.every(n => ...) => Boolean // ie9+
.some(n => ..) => Boolean   // ie9+
Comment

list of javascript cheat sheet

.find(n => ...)  // es6
.findIndex(...)  // es6
Comment

list of javascript cheat sheet

// before -- [_,_,NEW,REF,_,_]
list.splice(list.indexOf(REF), 0, NEW))
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

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

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

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

js Cheat sheet

<script type="text/javascript">

//JS code goes here

</script>
Comment

list of javascript cheat sheet

list.push(X)            // list == [_,_,_,_,_,X]
list.unshift(X)         // list == [X,_,_,_,_,_]
list.splice(2, 0, X)    // list == [_,_,X,_,_,_]
Comment

list of javascript cheat sheet

.map(n => ...)   // ie9+
.reduce((total, n) => total) // ie9+
.reduceRight(...)
Comment

list of javascript cheat sheet

.filter(n => ...) => array
Comment

list of javascript cheat sheet

// after -- [_,_,REF,NEW,_,_]
list.splice(list.indexOf(REF)+1, 0, NEW))
Comment

list of javascript cheat sheet

re = list.splice(1)     // re = [b,c,d,e]  list == [a]
re = list.splice(1,2)   // re = [b,c]      list == [a,d,e]
Comment

list of javascript cheat sheet

list = [a,b,c,d,e]
Comment

dom javascript cheat sheet

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

list of javascript cheat sheet

list.splice(2, 1, X)    // list == [a,b,X,d,e]
Comment

javascript array methods cheat sheet

// example
[ "x", "y", "z" ].join(" - ") // "x - y - z"
// syntax
arr.join([separator])
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 :: mapview hooks glitch 
Javascript :: js.l1 
Javascript :: js catch errors on listeners 
Javascript :: query relation data in mongoose 
Javascript :: ab mob react native expo 
Javascript :: react native tdd emzyme 
Javascript :: html check template browser 
Javascript :: javascript program name 
Javascript :: function every time you route angular 
Javascript :: load data table app script 
Javascript :: firstdata payment.js Form Validity 
Javascript :: find only vowels in string Javascript 
Javascript :: onpress react native datepicker stackver flow 
Javascript :: stop monitorevents 
Javascript :: javascript select element have long word 
Javascript :: get number of elements in hashmap javascript 
Javascript :: attach a generated pdf to a smtpjs mail in js 
Javascript :: how to store and extract local storage 
Javascript :: open bytes in new tab angular 
Javascript :: Getting Nan when calculate two date js 
Javascript :: att asm jmp 
Javascript :: quasar composition api $q 
Javascript :: monorepos nx nestjs docker 
Javascript :: remove a function added to eventhandler 
Javascript :: how to set Json node in java 
Javascript :: reqeuest body in hapijs 
Javascript :: fluentmigrator update row where 
Javascript :: javascript 2 decimal float array elements 
Javascript :: js match true false 
Javascript :: load bmfont three with webpack 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =